2024-05-01 22:14:04 +00:00
|
|
|
{ lib }:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (lib) mkIf versionAtLeast versionOlder;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
|
|
|
|
# Keeping these around in case we decide to change this horrible implementation :)
|
2024-06-30 08:16:52 +00:00
|
|
|
option = x: x // { optional = true; };
|
2024-05-01 22:14:04 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
yes = {
|
|
|
|
tristate = "y";
|
|
|
|
optional = false;
|
|
|
|
};
|
|
|
|
no = {
|
|
|
|
tristate = "n";
|
|
|
|
optional = false;
|
|
|
|
};
|
|
|
|
module = {
|
|
|
|
tristate = "m";
|
|
|
|
optional = false;
|
|
|
|
};
|
|
|
|
unset = {
|
|
|
|
tristate = null;
|
|
|
|
optional = false;
|
|
|
|
};
|
|
|
|
freeform = x: {
|
|
|
|
freeform = x;
|
|
|
|
optional = false;
|
|
|
|
};
|
2024-05-01 22:14:04 +00:00
|
|
|
|
|
|
|
# Common patterns/legacy used in common-config/hardened/config.nix
|
|
|
|
whenHelpers = version: {
|
|
|
|
whenAtLeast = ver: mkIf (versionAtLeast version ver);
|
2024-06-30 08:16:52 +00:00
|
|
|
whenOlder = ver: mkIf (versionOlder version ver);
|
2024-05-01 22:14:04 +00:00
|
|
|
# range is (inclusive, exclusive)
|
|
|
|
whenBetween = verLow: verHigh: mkIf (versionAtLeast version verLow && versionOlder version verHigh);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|