core/lib/kernel.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
854 B
Nix
Raw Normal View History

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 :)
option = x: x // { optional = true; };
2024-06-30 08:16:52 +00:00
yes = {
2024-05-01 22:14:04 +00:00
tristate = "y";
optional = false;
2024-06-30 08:16:52 +00:00
};
no = {
2024-05-01 22:14:04 +00:00
tristate = "n";
optional = false;
2024-06-30 08:16:52 +00:00
};
2024-05-01 22:14:04 +00:00
module = {
tristate = "m";
optional = false;
2024-06-30 08:16:52 +00:00
};
2024-05-01 22:14:04 +00:00
unset = {
tristate = null;
optional = false;
2024-06-30 08:16:52 +00:00
};
2024-05-01 22:14:04 +00:00
freeform = x: {
freeform = x;
optional = false;
2024-06-30 08:16:52 +00:00
};
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);
whenOlder = ver: mkIf (versionOlder version ver);
# range is (inclusive, exclusive)
whenBetween = verLow: verHigh: mkIf (versionAtLeast version verLow && versionOlder version verHigh);
};
}