* Use the copy-from-other-stores substituter by default. Of course,

it only does something if $NIX_OTHER_STORES (not really a good
  name...) is set.
* Do globbing on the elements of $NIX_OTHER_STORES.  E.g. you could
  set it to /mnts/*/nix or something.
* Install substituters in libexec/nix/substituters.
This commit is contained in:
Eelco Dolstra 2008-07-18 13:05:10 +00:00
parent 15f39aba8c
commit 8bc591a6f0
3 changed files with 20 additions and 12 deletions

View file

@ -15,10 +15,12 @@ install-exec-local: readmanifest.pm download-using-manifests.pl copy-from-other-
$(INSTALL) -d $(DESTDIR)$(libexecdir)/nix $(INSTALL) -d $(DESTDIR)$(libexecdir)/nix
$(INSTALL_DATA) readmanifest.pm $(DESTDIR)$(libexecdir)/nix $(INSTALL_DATA) readmanifest.pm $(DESTDIR)$(libexecdir)/nix
$(INSTALL_DATA) readconfig.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) find-runtime-roots.pl $(DESTDIR)$(libexecdir)/nix
$(INSTALL_PROGRAM) generate-patches.pl $(DESTDIR)$(libexecdir)/nix $(INSTALL_PROGRAM) generate-patches.pl $(DESTDIR)$(libexecdir)/nix
$(INSTALL_PROGRAM) build-remote.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 $(INSTALL) -d $(DESTDIR)$(sysconfdir)/nix
include ../substitute.mk include ../substitute.mk

View file

@ -3,17 +3,18 @@
use strict; use strict;
use File::Basename; 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;
my @remoteStores = split ':', $ENV{"NIX_OTHER_STORES"}; foreach my $dir (@remoteStoresAll) {
push @remoteStores, glob($dir);
}
sub findStorePath { sub findStorePath {
my $storePath = shift; my $storePath = shift;
my $storePathName = basename $storePath; my $storePathName = basename $storePath;
#print STDERR "GET $storePath\n";
foreach my $store (@remoteStores) { foreach my $store (@remoteStores) {
# Determine whether $storePath exists by looking for the # Determine whether $storePath exists by looking for the
@ -26,7 +27,6 @@ sub findStorePath {
my $infoFile = "$store/var/nix/db/info/$storePathName"; my $infoFile = "$store/var/nix/db/info/$storePathName";
my $storePath2 = "$store/store/$storePathName"; my $storePath2 = "$store/store/$storePathName";
if (-f $infoFile && -e $storePath2) { if (-f $infoFile && -e $storePath2) {
#print STDERR "FOUND IN $infoFile\n";
return ($infoFile, $storePath2); return ($infoFile, $storePath2);
} }
} }
@ -34,7 +34,11 @@ sub findStorePath {
if ($ARGV[0] eq "--query-paths") { 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) { foreach my $storePath (@ARGV) {
(my $infoFile) = findStorePath $storePath; (my $infoFile) = findStorePath $storePath;
#print STDERR "XXX $infoFile\n"; next unless $infoFile;
my $deriver = ""; my $deriver = "";
my @references = (); my @references = ();
@ -73,8 +77,9 @@ elsif ($ARGV[0] eq "--substitute") {
die unless scalar @ARGV == 2; die unless scalar @ARGV == 2;
my $storePath = $ARGV[1]; my $storePath = $ARGV[1];
(my $infoFile, my $sourcePath) = findStorePath $storePath; (my $infoFile, my $sourcePath) = findStorePath $storePath;
die unless $infoFile;
print "\n*** Copying `$storePath' from `$sourcePath'\n\n"; 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'"; or die "cannot copy `$sourcePath' to `$storePath'";
} }

View file

@ -111,9 +111,10 @@ static void initAndRun(int argc, char * * argv)
nixBinDir = canonPath(getEnv("NIX_BIN_DIR", NIX_BIN_DIR)); nixBinDir = canonPath(getEnv("NIX_BIN_DIR", NIX_BIN_DIR));
string subs = getEnv("NIX_SUBSTITUTERS", "default"); string subs = getEnv("NIX_SUBSTITUTERS", "default");
if (subs == "default") if (subs == "default") {
substituters.push_back(nixLibexecDir + "/nix/download-using-manifests.pl"); substituters.push_back(nixLibexecDir + "/nix/substituters/copy-from-other-stores.pl");
else substituters.push_back(nixLibexecDir + "/nix/substituters/download-using-manifests.pl");
} else
substituters = tokenizeString(subs, ":"); substituters = tokenizeString(subs, ":");
/* Get some settings from the configuration file. */ /* Get some settings from the configuration file. */