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