mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
c0f5f271d1
* doc: migrate trivial files to doc-comment format * fix: revert some comments * Apply suggestions from code review Thanks @danielSidhion Co-authored-by: Daniel Sidhion <DanielSidhion@users.noreply.github.com> * Update lib/types.nix --------- Co-authored-by: Daniel Sidhion <DanielSidhion@users.noreply.github.com> Co-authored-by: Silvan Mosberger <github@infinisil.com>
29 lines
845 B
Nix
29 lines
845 B
Nix
{ 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; };
|
|
|
|
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; };
|
|
|
|
|
|
# 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);
|
|
};
|
|
|
|
}
|