nix: Allow excluding features, allow disabling release_max_log_level

This commit is contained in:
morguldir 2024-05-24 20:22:11 +02:00 committed by June 🍓🦴
parent 5893901a75
commit 9aa372d83b

View file

@ -14,7 +14,9 @@
# Options (keep sorted) # Options (keep sorted)
, default_features ? true , default_features ? true
, disable_release_max_log_level ? false
, all_features ? false , all_features ? false
, disable_features ? []
, features ? [] , features ? []
, profile ? "release" , profile ? "release"
}: }:
@ -41,8 +43,10 @@ features' = lib.unique
(features ++ (features ++
lib.optionals default_features allDefaultFeatures ++ lib.optionals default_features allDefaultFeatures ++
lib.optionals all_features allFeatures); lib.optionals all_features allFeatures);
disable_features' = disable_features ++ lib.optionals disable_release_max_log_level ["release_max_log_level"];
features'' = lib.subtractLists disable_features' features';
featureEnabled = feature : builtins.elem feature features'; featureEnabled = feature : builtins.elem feature features'';
# This derivation will set the JEMALLOC_OVERRIDE variable, causing the # This derivation will set the JEMALLOC_OVERRIDE variable, causing the
# tikv-jemalloc-sys crate to use the nixpkgs jemalloc instead of building it's # tikv-jemalloc-sys crate to use the nixpkgs jemalloc instead of building it's
@ -161,8 +165,8 @@ craneLib.buildPackage ( commonAttrs // {
cargoExtraArgs = "--no-default-features " cargoExtraArgs = "--no-default-features "
+ lib.optionalString + lib.optionalString
(features' != []) (features'' != [])
"--features " + (builtins.concatStringsSep "," features'); "--features " + (builtins.concatStringsSep "," features'');
# This is redundant with CI # This is redundant with CI
cargoTestCommand = ""; cargoTestCommand = "";