summary refs log tree commit diff
path: root/lib/types.nix
diff options
context:
space:
mode:
authorRobert Hensing <roberth@users.noreply.github.com>2020-10-26 06:59:17 +0100
committerGitHub <noreply@github.com>2020-10-26 06:59:17 +0100
commit7102388834f1cd81c4d4bc48f41f0d4b8fa8933a (patch)
tree5f756199db6db3ec9056b488ae90c9cd242a4333 /lib/types.nix
parentdfaa313d437d8de52e0e174570ecc95eed87bab2 (diff)
parenta4019a40b310912a5ba91c15cf5aa4a6a4a9376f (diff)
downloadnixpkgs-7102388834f1cd81c4d4bc48f41f0d4b8fa8933a.tar
nixpkgs-7102388834f1cd81c4d4bc48f41f0d4b8fa8933a.tar.gz
nixpkgs-7102388834f1cd81c4d4bc48f41f0d4b8fa8933a.tar.bz2
nixpkgs-7102388834f1cd81c4d4bc48f41f0d4b8fa8933a.tar.lz
nixpkgs-7102388834f1cd81c4d4bc48f41f0d4b8fa8933a.tar.xz
nixpkgs-7102388834f1cd81c4d4bc48f41f0d4b8fa8933a.tar.zst
nixpkgs-7102388834f1cd81c4d4bc48f41f0d4b8fa8933a.zip
Merge pull request #101139 from roberth/lib-use-static-scope-checking
lib: Use Nix's static scope checking, fix error message, optimize
Diffstat (limited to 'lib/types.nix')
-rw-r--r--lib/types.nix62
1 files changed, 56 insertions, 6 deletions
diff --git a/lib/types.nix b/lib/types.nix
index 30b053db486..77f32f48ea2 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -1,12 +1,62 @@
 # Definitions related to run-time type checking.  Used in particular
 # to type-check NixOS configurations.
 { lib }:
-with lib.lists;
-with lib.attrsets;
-with lib.options;
-with lib.trivial;
-with lib.strings;
+
 let
+  inherit (lib)
+    elem
+    flip
+    functionArgs
+    isAttrs
+    isBool
+    isDerivation
+    isFloat
+    isFunction
+    isInt
+    isList
+    isString
+    isStorePath
+    setFunctionArgs
+    toDerivation
+    toList
+    ;
+  inherit (lib.lists)
+    all
+    concatLists
+    count
+    elemAt
+    filter
+    foldl'
+    head
+    imap1
+    last
+    length
+    tail
+    unique
+    ;
+  inherit (lib.attrsets)
+    attrNames
+    filterAttrs
+    hasAttr
+    mapAttrs
+    optionalAttrs
+    zipAttrsWith
+    ;
+  inherit (lib.options)
+    getFiles
+    getValues
+    mergeDefaultOption
+    mergeEqualOption
+    mergeOneOption
+    showFiles
+    showOption
+    ;
+  inherit (lib.strings)
+    concatMapStringsSep
+    concatStringsSep
+    escapeNixString
+    isCoercibleToString
+    ;
 
   inherit (lib.modules) mergeDefinitions;
   outer_types =
@@ -270,7 +320,7 @@ rec {
       name = "attrs";
       description = "attribute set";
       check = isAttrs;
-      merge = loc: foldl' (res: def: mergeAttrs res def.value) {};
+      merge = loc: foldl' (res: def: res // def.value) {};
       emptyValue = { value = {}; };
     };