Fix backward compatibility with Nix < 1.6
"with" used to be less lazy, so don't rely on that. Also don't use the "<" operator.
This commit is contained in:
parent
f3cdf9b477
commit
a61b800da5
@ -1,5 +1,9 @@
|
|||||||
with import ./.. {};
|
with import ./lists.nix;
|
||||||
with lib;
|
with import ./trivial.nix;
|
||||||
|
with import ./attrsets.nix;
|
||||||
|
with import ./options.nix;
|
||||||
|
with import ./debug.nix;
|
||||||
|
with import ./types.nix;
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
|
||||||
@ -244,7 +248,7 @@ rec {
|
|||||||
let
|
let
|
||||||
defaultPrio = 100;
|
defaultPrio = 100;
|
||||||
getPrio = def: if def.value._type or "" == "override" then def.value.priority else defaultPrio;
|
getPrio = def: if def.value._type or "" == "override" then def.value.priority else defaultPrio;
|
||||||
min = x: y: if x < y then x else y;
|
min = x: y: if builtins.lessThan x y then x else y;
|
||||||
highestPrio = fold (def: prio: min (getPrio def) prio) 9999 defs;
|
highestPrio = fold (def: prio: min (getPrio def) prio) 9999 defs;
|
||||||
strip = def: if def.value._type or "" == "override" then def // { value = def.value.content; } else def;
|
strip = def: if def.value._type or "" == "override" then def // { value = def.value.content; } else def;
|
||||||
in concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
|
in concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
# Definitions related to run-time type checking. Used in particular
|
# Definitions related to run-time type checking. Used in particular
|
||||||
# to type-check NixOS configurations.
|
# to type-check NixOS configurations.
|
||||||
|
|
||||||
let lib = import ./default.nix; in
|
with import ./lists.nix;
|
||||||
|
with import ./attrsets.nix;
|
||||||
with lib.lists;
|
with import ./options.nix;
|
||||||
with lib.attrsets;
|
with import ./trivial.nix;
|
||||||
with lib.options;
|
with import ./strings.nix;
|
||||||
with lib.trivial;
|
|
||||||
with lib.modules;
|
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
|
||||||
@ -51,7 +49,7 @@ rec {
|
|||||||
bool = mkOptionType {
|
bool = mkOptionType {
|
||||||
name = "boolean";
|
name = "boolean";
|
||||||
check = builtins.isBool;
|
check = builtins.isBool;
|
||||||
merge = loc: fold (x: lib.or x.value) false;
|
merge = loc: fold (x: y: x.value || y) false;
|
||||||
};
|
};
|
||||||
|
|
||||||
int = mkOptionType {
|
int = mkOptionType {
|
||||||
@ -71,7 +69,7 @@ rec {
|
|||||||
separatedString = sep: mkOptionType {
|
separatedString = sep: mkOptionType {
|
||||||
name = "string";
|
name = "string";
|
||||||
check = builtins.isString;
|
check = builtins.isString;
|
||||||
merge = loc: defs: lib.concatStringsSep sep (getValues defs);
|
merge = loc: defs: concatStringsSep sep (getValues defs);
|
||||||
};
|
};
|
||||||
|
|
||||||
lines = separatedString "\n";
|
lines = separatedString "\n";
|
||||||
@ -85,7 +83,7 @@ rec {
|
|||||||
attrs = mkOptionType {
|
attrs = mkOptionType {
|
||||||
name = "attribute set";
|
name = "attribute set";
|
||||||
check = isAttrs;
|
check = isAttrs;
|
||||||
merge = loc: fold (def: lib.mergeAttrs def.value) {};
|
merge = loc: fold (def: mergeAttrs def.value) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
# derivation is a reserved keyword.
|
# derivation is a reserved keyword.
|
||||||
@ -117,7 +115,7 @@ rec {
|
|||||||
|
|
||||||
attrsOf = elemType: mkOptionType {
|
attrsOf = elemType: mkOptionType {
|
||||||
name = "attribute set of ${elemType.name}s";
|
name = "attribute set of ${elemType.name}s";
|
||||||
check = x: isAttrs x && all elemType.check (lib.attrValues x);
|
check = x: isAttrs x && all elemType.check (attrValues x);
|
||||||
merge = loc: defs:
|
merge = loc: defs:
|
||||||
zipAttrsWith (name: elemType.merge (loc ++ [name]))
|
zipAttrsWith (name: elemType.merge (loc ++ [name]))
|
||||||
# Push down position info.
|
# Push down position info.
|
||||||
@ -179,7 +177,10 @@ rec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
submodule = opts:
|
submodule = opts:
|
||||||
let opts' = toList opts; in
|
let
|
||||||
|
opts' = toList opts;
|
||||||
|
inherit (import ./modules.nix) evalModules;
|
||||||
|
in
|
||||||
mkOptionType rec {
|
mkOptionType rec {
|
||||||
name = "submodule";
|
name = "submodule";
|
||||||
check = x: isAttrs x || builtins.isFunction x;
|
check = x: isAttrs x || builtins.isFunction x;
|
||||||
|
Loading…
Reference in New Issue
Block a user