2020-04-24 23:36:52 +00:00
|
|
|
{ lib }:
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
let
|
|
|
|
inherit (lib) mkIf versionAtLeast versionOlder;
|
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
# Keeping these around in case we decide to change this horrible implementation :)
|
|
|
|
option = x:
|
|
|
|
x // { optional = true; };
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
yes = { tristate = "y"; optional = false; };
|
|
|
|
no = { tristate = "n"; optional = false; };
|
|
|
|
module = { tristate = "m"; optional = false; };
|
|
|
|
unset = { tristate = null; optional = false; };
|
2020-06-18 07:06:33 +00:00
|
|
|
freeform = x: { freeform = x; optional = false; };
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
# Common patterns/legacy used in common-config/hardened/config.nix
|
2020-04-24 23:36:52 +00:00
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|