* Move the implementation of the ‘derivation’ primop into a separate

file.
This commit is contained in:
Eelco Dolstra 2012-01-03 14:01:47 +00:00
parent 6c31232e14
commit 921111d197
4 changed files with 35 additions and 26 deletions

View file

@ -1,6 +1,6 @@
all-local: config.nix
files = nar.nix buildenv.nix buildenv.pl unpack-channel.nix unpack-channel.sh
files = nar.nix buildenv.nix buildenv.pl unpack-channel.nix unpack-channel.sh derivation.nix
install-exec-local:
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs

31
corepkgs/derivation.nix Normal file
View file

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