diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2012-01-03 14:01:47 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2012-01-03 14:01:47 +0000 |
commit | 921111d1972388a0aa1841c545c753cb996c9257 (patch) | |
tree | ab965ec07c63db0649c8d9871f6c72813b2696a9 /corepkgs/derivation.nix | |
parent | 6c31232e1494d1d68a31fb8433dbf593f831dff2 (diff) |
* Move the implementation of the ‘derivation’ primop into a separate
file.
Diffstat (limited to 'corepkgs/derivation.nix')
-rw-r--r-- | corepkgs/derivation.nix | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/corepkgs/derivation.nix b/corepkgs/derivation.nix new file mode 100644 index 000000000..0e16ad6fa --- /dev/null +++ b/corepkgs/derivation.nix @@ -0,0 +1,31 @@ +attrs: + +let + + strict = derivationStrict attrs; + + attrValues = attrs: + map (name: builtins.getAttr name attrs) (builtins.attrNames attrs); + + outputToAttrListElement = output: + { name = output; + value = attrs // { + outPath = builtins.getAttr (output + "Path") strict; + drvPath = strict.drvPath; + type = "derivation"; + currentOutput = output; + } // outputsAttrs // { all = allList; }; + }; + + outputsList = + if attrs ? outputs + then map outputToAttrListElement attrs.outputs + else [ (outputToAttrListElement "out") ]; + + outputsAttrs = builtins.listToAttrs outputsList; + + allList = attrValues outputsAttrs; + + head = if attrs ? outputs then builtins.head attrs.outputs else "out"; + +in builtins.getAttr head outputsAttrs |