about summary refs log tree commit diff
path: root/corepkgs
diff options
context:
space:
mode:
Diffstat (limited to 'corepkgs')
-rw-r--r--corepkgs/buildenv.nix14
-rw-r--r--corepkgs/buildenv.pl33
2 files changed, 25 insertions, 22 deletions
diff --git a/corepkgs/buildenv.nix b/corepkgs/buildenv.nix
index 50c9923af79f..923778379263 100644
--- a/corepkgs/buildenv.nix
+++ b/corepkgs/buildenv.nix
@@ -2,18 +2,22 @@ with import <nix/config.nix>;
 
 { derivations, manifest }:
 
-derivation { 
+derivation {
   name = "user-environment";
   system = builtins.currentSystem;
   builder = perl;
   args = [ "-w" ./buildenv.pl ];
-  
+
   manifest = manifest;
 
   # !!! grmbl, need structured data for passing this in a clean way.
-  paths = derivations;
-  active = map (x: if x ? meta && x.meta ? active then x.meta.active else "true") derivations;
-  priority = map (x: if x ? meta && x.meta ? priority then x.meta.priority else "5") derivations;
+  derivations =
+    map (d:
+      [ (if d.meta.active or true then "1" else "0")
+        (d.meta.priority or 5)
+        (builtins.length d.outputs)
+      ] ++ map (output: builtins.getAttr output d) d.outputs)
+      derivations;
 
   # Building user environments remotely just causes huge amounts of
   # network traffic, so don't do that.
diff --git a/corepkgs/buildenv.pl b/corepkgs/buildenv.pl
index 52a703c0668f..3d79e50316fd 100644
--- a/corepkgs/buildenv.pl
+++ b/corepkgs/buildenv.pl
@@ -43,12 +43,12 @@ sub createLinks {
             $srcFile =~ /\/log$/)
         {
             # Do nothing.
-	}
+        }
 
         elsif (-d $srcFile) {
 
             lstat $dstFile;
-            
+
             if (-d _) {
                 createLinks($srcFile, $dstFile, $priority);
             }
@@ -59,7 +59,7 @@ sub createLinks {
                     die "collission between directory `$srcFile' and non-directory `$target'";
                 }
                 unlink $dstFile or die "error unlinking `$dstFile': $!";
-                mkdir $dstFile, 0755 || 
+                mkdir $dstFile, 0755 ||
                     die "error creating directory `$dstFile': $!";
                 createLinks($target, $dstFile, $priorities{$dstFile});
                 createLinks($srcFile, $dstFile, $priority);
@@ -86,7 +86,7 @@ sub createLinks {
                 next if $prevPriority < $priority;
                 unlink $dstFile or die;
             }
-            
+
             symlink($srcFile, $dstFile) ||
                 die "error creating link `$dstFile': $!";
             $priorities{$dstFile} = $priority;
@@ -125,19 +125,18 @@ sub addPkg {
 
 # Convert the stuff we get from the environment back into a coherent
 # data type.
-my @paths = split ' ', $ENV{"paths"};
-my @active = split ' ', $ENV{"active"};
-my @priority = split ' ', $ENV{"priority"};
-
-die if scalar @paths != scalar @active;
-die if scalar @paths != scalar @priority;
-
 my %pkgs;
-
-for (my $n = 0; $n < scalar @paths; $n++) {
-    $pkgs{$paths[$n]} =
-        { active => $active[$n]
-        , priority => $priority[$n] };
+my @derivations = split ' ', $ENV{"derivations"};
+while (scalar @derivations) {
+    my $active = shift @derivations;
+    my $priority = shift @derivations;
+    my $outputs = shift @derivations;
+    for (my $n = 0; $n < $outputs; $n++) {
+        my $path = shift @derivations;
+        $pkgs{$path} =
+            { active => int($active)
+            , priority => int($priority) };
+    }
 }
 
 
@@ -145,7 +144,7 @@ for (my $n = 0; $n < scalar @paths; $n++) {
 # user.
 foreach my $pkg (sort (keys %pkgs)) {
     #print $pkg, " ", $pkgs{$pkg}->{priority}, "\n";
-    addPkg($pkg, $pkgs{$pkg}->{priority}) if $pkgs{$pkg}->{active} ne "false";
+    addPkg($pkg, $pkgs{$pkg}->{priority}) if $pkgs{$pkg}->{active};
 }