From 26c2b79f6a6380ae3224e9309b9f3352f5717bd7 Mon Sep 17 00:00:00 2001 From: Vika Date: Sat, 29 Jul 2023 21:25:56 +0300 Subject: kittybox.nix: properly set the features and don't rely on defaults --- kittybox.nix | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'kittybox.nix') diff --git a/kittybox.nix b/kittybox.nix index ccf3ea8..22e774c 100644 --- a/kittybox.nix +++ b/kittybox.nix @@ -6,16 +6,22 @@ assert useWebAuthn -> openssl != null && pkg-config != null; assert usePostgres -> postgresql != null && postgresqlTestHook != null; -naersk.buildPackage { +let + featureMatrix = features: lib.concatStringsSep " " (lib.attrNames (lib.filterAttrs (k: v: v) features)); +in +naersk.buildPackage rec { pname = "kittybox"; version = "0.1.0"; - src = ./kittybox-rs; + src = lib.sources.sourceFilesBySuffices ./kittybox-rs [".rs" ".toml" ".sql" ".ts" ".css" ".html" ".lock" ".json"]; doCheck = stdenv.hostPlatform == stdenv.targetPlatform; - cargoOptions = x: x ++ (lib.optionals useWebAuthn [ - "--no-default-features" "--features=\"webauthn${lib.optionalString usePostgres " sqlx"}\"" - ]); + cargoBuildOptions = x: x ++ [ + "--no-default-features" + "--features=\"${featureMatrix { webauthn = useWebAuthn; postgres = usePostgres; rustls = !useWebAuthn; }}\"" + ]; + cargoTestOptions = cargoBuildOptions; + buildInputs = lib.optional useWebAuthn openssl; nativeBuildInputs = [ typescript ] ++ (lib.optional useWebAuthn pkg-config); -- cgit 1.4.1