3
0
Fork 0
forked from mirrors/nixpkgs

lib.kernel: scoped whenXXX helpers

whenAtLeast/whenBetween are made available in lib/kernel.nix but are now
scoped under whenXXX.
This commit is contained in:
Matthieu Coudron 2019-09-19 20:12:35 +09:00
parent afa0e02d64
commit a4fe469d39
3 changed files with 13 additions and 5 deletions

View file

@ -13,4 +13,14 @@ with lib;
module = { tristate = "m"; };
freeform = x: { freeform = x; };
/*
Common patterns/legacy used in common-config/hardened-config.nix
*/
whenHelpers = version: {
whenAtLeast = ver: mkIf (versionAtLeast version ver);
whenOlder = ver: mkIf (versionOlder version ver);
# range is (inclusive, exclusive)
whenBetween = verLow: verHigh: mkIf (versionAtLeast version verLow && versionOlder version verHigh);
};
}

View file

@ -17,13 +17,9 @@
with stdenv.lib;
with stdenv.lib.kernel;
with (stdenv.lib.kernel.whenHelpers version);
let
# Common patterns/legacy
whenAtLeast = ver: mkIf (versionAtLeast version ver);
whenOlder = ver: mkIf (versionOlder version ver);
# range is (inclusive, exclusive)
whenBetween = verLow: verHigh: mkIf (versionAtLeast version verLow && versionOlder version verHigh);
# configuration items have to be part of a subattrs

View file

@ -12,6 +12,8 @@
with stdenv.lib;
with stdenv.lib.kernel;
with (stdenv.lib.kernel.whenHelpers version);
assert (versionAtLeast version "4.9");
optionalAttrs (stdenv.hostPlatform.platform.kernelArch == "x86_64") {