about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--scripts/Makefile.am4
-rw-r--r--scripts/copy-from-other-stores.pl.in21
-rw-r--r--src/libmain/shared.cc7
3 files changed, 20 insertions, 12 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 6a6226ebe73b..d6af9806cee4 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -15,10 +15,12 @@ install-exec-local: readmanifest.pm download-using-manifests.pl copy-from-other-
 	$(INSTALL) -d $(DESTDIR)$(libexecdir)/nix
 	$(INSTALL_DATA) readmanifest.pm $(DESTDIR)$(libexecdir)/nix 
 	$(INSTALL_DATA) readconfig.pm $(DESTDIR)$(libexecdir)/nix 
-	$(INSTALL_PROGRAM) download-using-manifests.pl $(DESTDIR)$(libexecdir)/nix 
 	$(INSTALL_PROGRAM) find-runtime-roots.pl $(DESTDIR)$(libexecdir)/nix 
 	$(INSTALL_PROGRAM) generate-patches.pl $(DESTDIR)$(libexecdir)/nix 
 	$(INSTALL_PROGRAM) build-remote.pl $(DESTDIR)$(libexecdir)/nix 
+	$(INSTALL) -d $(DESTDIR)$(libexecdir)/nix/substituters
+	$(INSTALL_PROGRAM) download-using-manifests.pl $(DESTDIR)$(libexecdir)/nix/substituters
+	$(INSTALL_PROGRAM) copy-from-other-stores.pl $(DESTDIR)$(libexecdir)/nix/substituters
 	$(INSTALL) -d $(DESTDIR)$(sysconfdir)/nix
 
 include ../substitute.mk
diff --git a/scripts/copy-from-other-stores.pl.in b/scripts/copy-from-other-stores.pl.in
index 4f829108b0b8..74efbd7459e6 100644
--- a/scripts/copy-from-other-stores.pl.in
+++ b/scripts/copy-from-other-stores.pl.in
@@ -3,17 +3,18 @@
 use strict;
 use File::Basename;
 
-#print STDERR "FOO: @ARGV\n";
+my @remoteStoresAll = split ':', ($ENV{"NIX_OTHER_STORES"} or "");
 
-die unless defined $ENV{"NIX_OTHER_STORES"};
-my @remoteStores = split ':', $ENV{"NIX_OTHER_STORES"};
+my @remoteStores;
+foreach my $dir (@remoteStoresAll) {
+    push @remoteStores, glob($dir);
+}
 
 
 sub findStorePath {
     my $storePath = shift;
     
     my $storePathName = basename $storePath;
-    #print STDERR "GET $storePath\n";
     
     foreach my $store (@remoteStores) {
         # Determine whether $storePath exists by looking for the
@@ -26,7 +27,6 @@ sub findStorePath {
         my $infoFile = "$store/var/nix/db/info/$storePathName";
         my $storePath2 = "$store/store/$storePathName";
         if (-f $infoFile && -e $storePath2) {
-            #print STDERR "FOUND IN $infoFile\n";
             return ($infoFile, $storePath2);
         }
     }
@@ -34,7 +34,11 @@ sub findStorePath {
 
 
 if ($ARGV[0] eq "--query-paths") {
-    # !!! not implemented yet; needed for `nix-env -qas'
+    foreach my $store (@remoteStores) {
+        opendir DIR, "$store/var/nix/db/info" or next;
+        print "@storedir@/$_\n" foreach readdir DIR;
+        closedir DIR;
+    }
 }
 
 
@@ -44,7 +48,7 @@ elsif ($ARGV[0] eq "--query-info") {
     foreach my $storePath (@ARGV) {
 
         (my $infoFile) = findStorePath $storePath;
-        #print STDERR "XXX $infoFile\n";
+        next unless $infoFile;
         
         my $deriver = "";
         my @references = ();
@@ -73,8 +77,9 @@ elsif ($ARGV[0] eq "--substitute") {
     die unless scalar @ARGV == 2;
     my $storePath = $ARGV[1];
     (my $infoFile, my $sourcePath) = findStorePath $storePath;
+    die unless $infoFile;
     print "\n*** Copying `$storePath' from `$sourcePath'\n\n";
-    system("nix-store --dump $sourcePath | nix-store --restore $storePath") == 0
+    system("@bindir@/nix-store --dump $sourcePath | @bindir@/nix-store --restore $storePath") == 0
         or die "cannot copy `$sourcePath' to `$storePath'";
 }
 
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index d6f299d6bfda..36b4ebdc9c7a 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -111,9 +111,10 @@ static void initAndRun(int argc, char * * argv)
     nixBinDir = canonPath(getEnv("NIX_BIN_DIR", NIX_BIN_DIR));
 
     string subs = getEnv("NIX_SUBSTITUTERS", "default");
-    if (subs == "default")
-        substituters.push_back(nixLibexecDir + "/nix/download-using-manifests.pl");
-    else
+    if (subs == "default") {
+        substituters.push_back(nixLibexecDir + "/nix/substituters/copy-from-other-stores.pl");
+        substituters.push_back(nixLibexecDir + "/nix/substituters/download-using-manifests.pl");
+    } else
         substituters = tokenizeString(subs, ":");
 
     /* Get some settings from the configuration file. */