about summary refs log tree commit diff
path: root/scripts/nix-pull.in
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-09-25T11·11+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-09-25T11·11+0000
commitd43565c3e837feea478aaa71bad7e0a92c1911f0 (patch)
tree9fc6ee0e6bbc083160daf6739f8c69d08977b29e /scripts/nix-pull.in
parent68ae953d8a492061bcda7c4d7bf2f5b9432f791c (diff)
* In `nix-channel --update', skip manifests that assume a Nix store at
  a different location than the user's.  This makes channels usable as
  a source deployment mechanism for people who install Nix under
  non-standard prefixes.  (NIX-57)

Diffstat (limited to 'scripts/nix-pull.in')
-rw-r--r--scripts/nix-pull.in20
1 files changed, 19 insertions, 1 deletions
diff --git a/scripts/nix-pull.in b/scripts/nix-pull.in
index 0af036f6f302..c7c20fb9b7cc 100644
--- a/scripts/nix-pull.in
+++ b/scripts/nix-pull.in
@@ -21,6 +21,9 @@ $libexecDir = "@libexecdir@" unless defined $libexecDir;
 my $stateDir = $ENV{"NIX_STATE_DIR"};
 $stateDir = "@localstatedir@/nix" unless defined $stateDir;
 
+my $storeDir = $ENV{"NIX_STORE_DIR"};
+$storeDir = "@storedir@" unless defined $storeDir;
+
 
 # Prevent access problems in shared-stored installations.
 umask 0022;
@@ -31,6 +34,8 @@ my %narFiles;
 my %patches;
 my %successors;
 
+my $skipWrongStore = 0;
+
 sub processURL {
     my $url = shift;
 
@@ -45,6 +50,15 @@ sub processURL {
         die "manifest `$url' is too old (i.e., for Nix <= 0.7)\n";
     }
 
+    if ($skipWrongStore) {
+        foreach my $path (keys %narFiles) {
+            if (substr($path, 0, length($storeDir) + 1) ne "$storeDir/") {
+                print STDERR "warning: manifest `$url' assumes a Nix store at a different location than $storeDir, skipping...\n";
+                exit 0;
+            }
+        }
+    }
+
     my $baseName = "unnamed";
     if ($url =~ /\/([^\/]+)\/[^\/]+$/) { # get the forelast component
         $baseName = $1;
@@ -62,7 +76,11 @@ sub processURL {
 
 while (@ARGV) {
     my $url = shift @ARGV;
-    processURL $url;
+    if ($url eq "--skip-wrong-store") {
+        $skipWrongStore = 1;
+    } else {
+        processURL $url;
+    }
 }