Browse Source

Merge pull request #68491 from roberth/fix-dontRecurseIntoAttrs

Fix dontRecurseIntoAttrs + add to lib + doc
wip-nanopi-m4v2
Robert Hensing 6 years ago
committed by GitHub
parent
commit
e38a01db5d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 5 deletions
  1. +44
    -0
      doc/functions/library/attrsets.xml
  2. +14
    -0
      lib/attrsets.nix
  3. +2
    -1
      lib/default.nix
  4. +2
    -4
      pkgs/top-level/all-packages.nix

+ 44
- 0
doc/functions/library/attrsets.xml View File

@@ -1667,4 +1667,48 @@ recursiveUpdate
]]></programlisting>
</example>
</section>

<section xml:id="function-library-lib.attrsets.recurseIntoAttrs">
<title><function>lib.attrsets.recurseIntoAttrs</function></title>

<subtitle><literal>recurseIntoAttrs :: AttrSet -> AttrSet</literal>
</subtitle>

<xi:include href="./locations.xml" xpointer="lib.attrsets.recurseIntoAttrs" />

<para>
Make various Nix tools consider the contents of the resulting
attribute set when looking for what to build, find, etc.
</para>

<para>
This function only affects a single attribute set; it does not apply itself recursively for nested attribute sets.
</para>

<variablelist>
<varlistentry>
<term>
<varname>attrs</varname>
</term>
<listitem>
<para>
An attribute set to scan for derivations.
</para>
</listitem>
</varlistentry>
</variablelist>

<example xml:id="function-library-lib.attrsets.recurseIntoAttrs-example">
<title>Making Nix look inside an attribute set</title>
<programlisting><![CDATA[
{ pkgs ? import <nixpkgs> {} }:
{
myTools = pkgs.lib.recurseIntoAttrs {
inherit (pkgs) hello figlet;
};
}
]]></programlisting>
</example>
</section>

</section>

+ 14
- 0
lib/attrsets.nix View File

@@ -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;


+ 2
- 1
lib/default.nix View File

@@ -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


+ 2
- 4
pkgs/top-level/all-packages.nix View File

@@ -62,9 +62,7 @@ in

inherit (lib) lowPrio hiPrio appendToName makeOverridable;

# Applying this to an attribute set will cause nix-env to look
# inside the set for derivations.
recurseIntoAttrs = attrs: attrs // { recurseForDerivations = true; };
inherit (lib) recurseIntoAttrs;

# This is intended to be the reverse of recurseIntoAttrs, as it is
# defined now it exists mainly for documentation purposes, but you
@@ -72,7 +70,7 @@ in
# the Attrs which is useful for testing massive changes. Ideally,
# every package subset not marked with recurseIntoAttrs should be
# marked with this.
dontRecurseIntoAttrs = x: x;
inherit (lib) dontRecurseIntoAttrs;

stringsWithDeps = lib.stringsWithDeps;



Loading…
Cancel
Save