summary refs log tree commit diff
path: root/lib/types.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-30 19:12:25 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-30 19:12:25 +0100
commita61b800da50ca3106a5e7ffe1d808f3023d337b8 (patch)
treee61351877968306d9ae0909271c3c9f2e8caece5 /lib/types.nix
parentf3cdf9b47739d0018b2a022b3fdea1b940094803 (diff)
downloadnixpkgs-a61b800da50ca3106a5e7ffe1d808f3023d337b8.tar
nixpkgs-a61b800da50ca3106a5e7ffe1d808f3023d337b8.tar.gz
nixpkgs-a61b800da50ca3106a5e7ffe1d808f3023d337b8.tar.bz2
nixpkgs-a61b800da50ca3106a5e7ffe1d808f3023d337b8.tar.lz
nixpkgs-a61b800da50ca3106a5e7ffe1d808f3023d337b8.tar.xz
nixpkgs-a61b800da50ca3106a5e7ffe1d808f3023d337b8.tar.zst
nixpkgs-a61b800da50ca3106a5e7ffe1d808f3023d337b8.zip
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.
Diffstat (limited to 'lib/types.nix')
-rw-r--r--lib/types.nix25
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/types.nix b/lib/types.nix
index 2b3aa23df2f..09b29a762e1 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -1,13 +1,11 @@
 # Definitions related to run-time type checking.  Used in particular
 # to type-check NixOS configurations.
 
-let lib = import ./default.nix; in
-
-with lib.lists;
-with lib.attrsets;
-with lib.options;
-with lib.trivial;
-with lib.modules;
+with import ./lists.nix;
+with import ./attrsets.nix;
+with import ./options.nix;
+with import ./trivial.nix;
+with import ./strings.nix;
 
 rec {
 
@@ -51,7 +49,7 @@ rec {
     bool = mkOptionType {
       name = "boolean";
       check = builtins.isBool;
-      merge = loc: fold (x: lib.or x.value) false;
+      merge = loc: fold (x: y: x.value || y) false;
     };
 
     int = mkOptionType {
@@ -71,7 +69,7 @@ rec {
     separatedString = sep: mkOptionType {
       name = "string";
       check = builtins.isString;
-      merge = loc: defs: lib.concatStringsSep sep (getValues defs);
+      merge = loc: defs: concatStringsSep sep (getValues defs);
     };
 
     lines = separatedString "\n";
@@ -85,7 +83,7 @@ rec {
     attrs = mkOptionType {
       name = "attribute set";
       check = isAttrs;
-      merge = loc: fold (def: lib.mergeAttrs def.value) {};
+      merge = loc: fold (def: mergeAttrs def.value) {};
     };
 
     # derivation is a reserved keyword.
@@ -117,7 +115,7 @@ rec {
 
     attrsOf = elemType: mkOptionType {
       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:
         zipAttrsWith (name: elemType.merge (loc ++ [name]))
           # Push down position info.
@@ -179,7 +177,10 @@ rec {
     };
 
     submodule = opts:
-      let opts' = toList opts; in
+      let
+        opts' = toList opts;
+        inherit (import ./modules.nix) evalModules;
+      in
       mkOptionType rec {
         name = "submodule";
         check = x: isAttrs x || builtins.isFunction x;