2019-09-18 08:34:02 +00:00
|
|
|
{ lib }:
|
2016-01-05 14:22:43 +00:00
|
|
|
|
2024-03-11 15:04:13 +00:00
|
|
|
let
|
|
|
|
inherit (lib) mkIf versionAtLeast versionOlder;
|
|
|
|
in
|
2019-08-13 21:52:01 +00:00
|
|
|
{
|
2016-01-05 14:22:43 +00:00
|
|
|
|
2018-10-03 09:49:50 +00:00
|
|
|
# Keeping these around in case we decide to change this horrible implementation :)
|
|
|
|
option = x: x // { optional = true; };
|
2016-01-05 14:22:43 +00:00
|
|
|
|
2024-12-10 19:26:33 +00:00
|
|
|
yes = {
|
2023-04-29 18:33:07 +00:00
|
|
|
tristate = "y";
|
|
|
|
optional = false;
|
2024-12-10 19:26:33 +00:00
|
|
|
};
|
|
|
|
no = {
|
2023-04-29 18:33:07 +00:00
|
|
|
tristate = "n";
|
2020-04-01 01:20:33 +00:00
|
|
|
optional = false;
|
2024-12-10 19:26:33 +00:00
|
|
|
};
|
2023-04-29 18:33:07 +00:00
|
|
|
module = {
|
|
|
|
tristate = "m";
|
2020-04-01 01:20:33 +00:00
|
|
|
optional = false;
|
2024-12-10 19:26:33 +00:00
|
|
|
};
|
2023-04-29 18:33:07 +00:00
|
|
|
unset = {
|
|
|
|
tristate = null;
|
2020-04-01 01:20:33 +00:00
|
|
|
optional = false;
|
2024-12-10 19:26:33 +00:00
|
|
|
};
|
2020-04-01 01:20:33 +00:00
|
|
|
freeform = x: {
|
|
|
|
freeform = x;
|
|
|
|
optional = false;
|
2024-12-10 19:26:33 +00:00
|
|
|
};
|
2024-04-04 14:36:07 +00:00
|
|
|
|
|
|
|
# Common patterns/legacy used in common-config/hardened/config.nix
|
2019-09-19 11:12:35 +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);
|
|
|
|
};
|
|
|
|
|
2016-01-05 14:22:43 +00:00
|
|
|
}
|