about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2007-01-13T19·50+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2007-01-13T19·50+0000
commitafe23b5f385901ba5972ce88b2f053526c5097a9 (patch)
treefc65ae5a14e7260f130cd4417d7069b0ededdc60 /scripts
parentf25f9000451ec5b9fb3221cdf2a297fe24ab7357 (diff)
* nix-pack-closure: store the top-level store paths in the closure.
* nix-unpack-closure: extract the top-level paths from the closure and
  print them on stdout.  This allows them to be installed, e.g.,
  "nix-env -i $(nix-unpack-closure)".  (NIX-64)

Diffstat (limited to 'scripts')
-rw-r--r--scripts/nix-pack-closure.in7
-rw-r--r--scripts/nix-unpack-closure.in9
2 files changed, 16 insertions, 0 deletions
diff --git a/scripts/nix-pack-closure.in b/scripts/nix-pack-closure.in
index 6c0e85d2a69a..bc58097e25c1 100644
--- a/scripts/nix-pack-closure.in
+++ b/scripts/nix-pack-closure.in
@@ -21,6 +21,7 @@ mkdir "$tmpDir/contents", 0777 or die;
 mkdir "$tmpDir/references", 0777 or die;
 mkdir "$tmpDir/derivers", 0777 or die;
 
+open TOPLEVEL, ">$tmpDir/top-level" or die;
 
 
 my %storePaths;
@@ -29,6 +30,12 @@ my %storePaths;
 while (@ARGV) {
     my $storePath = shift @ARGV;
 
+    # $storePath might be a symlink to the store, so resolve it.
+    $storePath = (`$binDir/nix-store --query --resolve '$storePath'`
+        or die "cannot resolve `$storePath'");
+    chomp $storePath;
+    print TOPLEVEL $storePath, "\n";
+
     # Get the closure of this path.
     my $pid = open(READ,
         "$binDir/nix-store --query --requisites '$storePath'|") or die;
diff --git a/scripts/nix-unpack-closure.in b/scripts/nix-unpack-closure.in
index 89e7aa24d5cb..2b60bb4851dd 100644
--- a/scripts/nix-unpack-closure.in
+++ b/scripts/nix-unpack-closure.in
@@ -77,3 +77,12 @@ closedir(DIR) or die;
 # Register the invalid paths as valid.
 system("nix-store --register-validity <'$tmpDir/validity'") == 0
     or die "nix-store --register-validity failed";
+
+
+# Show the top-level paths so that something useful can be done with
+# them, e.g., passing them to `nix-env -i'.
+if (-e "$tmpDir/unpacked/top-level") {
+    open TOPLEVEL, "<$tmpDir/unpacked/top-level" or die;
+    while (<TOPLEVEL>) { print "$_"; }
+    close TOPLEVEL;
+}