summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorRobert Hensing <roberth@users.noreply.github.com>2020-03-01 11:05:34 +0100
committerGitHub <noreply@github.com>2020-03-01 11:05:34 +0100
commite38a01db5d8afe312d684e8c2ddbdb4e11d9307f (patch)
tree8e57912a3d467cbaab77fd558fdc7f71230734ab /lib
parent02ca096a85eced0d653004ae95f7cc6d8597b13e (diff)
parenta96f37db10fb2892d0420a7ef51c5b157d9e58dd (diff)
downloadnixpkgs-e38a01db5d8afe312d684e8c2ddbdb4e11d9307f.tar
nixpkgs-e38a01db5d8afe312d684e8c2ddbdb4e11d9307f.tar.gz
nixpkgs-e38a01db5d8afe312d684e8c2ddbdb4e11d9307f.tar.bz2
nixpkgs-e38a01db5d8afe312d684e8c2ddbdb4e11d9307f.tar.lz
nixpkgs-e38a01db5d8afe312d684e8c2ddbdb4e11d9307f.tar.xz
nixpkgs-e38a01db5d8afe312d684e8c2ddbdb4e11d9307f.tar.zst
nixpkgs-e38a01db5d8afe312d684e8c2ddbdb4e11d9307f.zip
Merge pull request #68491 from roberth/fix-dontRecurseIntoAttrs
Fix dontRecurseIntoAttrs + add to lib + doc
Diffstat (limited to 'lib')
-rw-r--r--lib/attrsets.nix14
-rw-r--r--lib/default.nix3
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/attrsets.nix b/lib/attrsets.nix
index 32994432d53..72430522f7d 100644
--- a/lib/attrsets.nix
+++ b/lib/attrsets.nix
@@ -473,6 +473,20 @@ rec {
   /* Pick the outputs of packages to place in buildInputs */
   chooseDevOutputs = drvs: builtins.map getDev drvs;
 
+  /* Make various Nix tools consider the contents of the resulting
+     attribute set when looking for what to build, find, etc.
+
+     This function only affects a single attribute set; it does not
+     apply itself recursively for nested attribute sets.
+   */
+  recurseIntoAttrs =
+    attrs: attrs // { recurseForDerivations = true; };
+
+  /* Undo the effect of recurseIntoAttrs.
+   */
+  dontRecurseIntoAttrs =
+    attrs: attrs // { recurseForDerivations = false; };
+
   /*** deprecated stuff ***/
 
   zipWithNames = zipAttrsWithNames;
diff --git a/lib/default.nix b/lib/default.nix
index d2fe018aa6a..f8cc5c4d816 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -73,7 +73,8 @@ let
       genAttrs isDerivation toDerivation optionalAttrs
       zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
       recursiveUpdate matchAttrs overrideExisting getOutput getBin
-      getLib getDev chooseDevOutputs zipWithNames zip;
+      getLib getDev chooseDevOutputs zipWithNames zip
+      recurseIntoAttrs dontRecurseIntoAttrs;
     inherit (lists) singleton forEach foldr fold foldl foldl' imap0 imap1
       concatMap flatten remove findSingle findFirst any all count
       optional optionals toList range partition zipListsWith zipLists