Allow customizing features

This commit is contained in:
Natsu Kagami 2023-06-20 01:12:02 +02:00
parent bd9a5a1b1d
commit 26b0e3b21d
Signed by: nki
GPG key ID: 55A032EB38B49ADB
2 changed files with 39 additions and 19 deletions

View file

@ -10,30 +10,14 @@
extra-substituters = [ "https://natsukagami.cachix.org" ];
trusted-public-keys = [ "natsukagami.cachix.org-1:3U6GV8i8gWEaXRUuXd2S4ASfYgdl2QFPWg4BKPbmYiQ=" ];
};
outputs = { self, nixpkgs, naersk, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system:
outputs = { self, nixpkgs, flake-utils, ... }@inputs: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
naersk' = pkgs.callPackage naersk { };
naersk = pkgs.callPackage inputs.naersk { };
in
rec {
packages.youmubot = naersk'.buildPackage {
name = "youmubot";
version = "0.1.0";
root = ./.;
cargoBuildOptions = opts: opts ++ [ "--package youmubot" ];
buildInputs = with pkgs; [
openssl
];
nativeBuildInputs = nixpkgs.lib.optionals pkgs.stdenv.isLinux (with pkgs; [
pkg-config
]);
SQLX_OFFLINE = "true";
};
packages.youmubot = pkgs.callPackage ./package.nix { inherit naersk; };
defaultPackage = packages.youmubot;

36
package.nix Normal file
View file

@ -0,0 +1,36 @@
{ naersk
, lib
, stdenv
, pkg-config
, openssl
, enableCodeforces ? true
, enableOsu ? true
, ...
}:
let
customizeFeatures = !(enableCodeforces && enableOsu);
featureFlags = lib.optionals customizeFeatures (
[ "--no-default-features" "--features=core" ]
++ lib.optional enableCodeforces "--features=codeforces"
++ lib.optional enableOsu "--features=osu"
);
in
naersk.buildPackage {
name = "youmubot";
version = "0.1.0";
root = ./.;
cargoBuildOptions = opts: opts ++ [ "--package youmubot" ] ++ featureFlags;
buildInputs = [
openssl
];
nativeBuildInputs = lib.optionals stdenv.isLinux [
pkg-config
];
SQLX_OFFLINE = "true";
}