summary refs log tree commit diff
path: root/corepkgs/derivation.nix
blob: 0e16ad6fa300c6dd437457a72e8f7038aa0151b4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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