mirror of
https://github.com/NixOS/nix.git
synced 2025-11-11 21:16:02 +01:00
* Extended the `inherit' syntax to optionally select attributes from
other attribute sets, rather than the current scope. E.g.,
{inherit (pkgs) gcc binutils;}
is equivalent to
{gcc = pkgs.gcc; binutils = pkgs.binutils;}
I am not so happy about the syntax.
This commit is contained in:
parent
9d25466b34
commit
d445da7a7b
2 changed files with 18 additions and 8 deletions
|
|
@ -50,11 +50,16 @@ ATerm fixAttrs(int recursive, ATermList as)
|
|||
ATermList * is = recursive ? &cs : &bs;
|
||||
for (ATermIterator i(as); i; ++i) {
|
||||
ATermList names;
|
||||
if (atMatch(m, *i) >> "Inherit" >> names)
|
||||
for (ATermIterator j(names); j; ++j)
|
||||
*is = ATinsert(*is,
|
||||
ATmake("Bind(<term>, Var(<term>))", *j, *j));
|
||||
else bs = ATinsert(bs, *i);
|
||||
Expr src;
|
||||
if (atMatch(m, *i) >> "Inherit" >> src >> names) {
|
||||
bool fromScope = atMatch(m, src) >> "Scope";
|
||||
for (ATermIterator j(names); j; ++j) {
|
||||
Expr rhs = fromScope
|
||||
? ATmake("Var(<term>)", *j)
|
||||
: ATmake("Select(<term>, <term>)", src, *j);
|
||||
*is = ATinsert(*is, ATmake("Bind(<term>, <term>)", *j, rhs));
|
||||
}
|
||||
} else bs = ATinsert(bs, *i);
|
||||
}
|
||||
if (recursive)
|
||||
return ATmake("Rec(<term>, <term>)", bs, cs);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue