Merge from trunk
This commit is contained in:
		
						commit
						2721e9f56f
					
				
					 73 changed files with 759 additions and 446 deletions
				
			
		|  | @ -1,4 +1,4 @@ | ||||||
| SUBDIRS = externals src scripts corepkgs doc misc tests | SUBDIRS = externals src perl scripts corepkgs doc misc tests | ||||||
| EXTRA_DIST = substitute.mk nix.spec nix.spec.in bootstrap.sh \ | EXTRA_DIST = substitute.mk nix.spec nix.spec.in bootstrap.sh \ | ||||||
|   nix.conf.example NEWS version |   nix.conf.example NEWS version | ||||||
| 
 | 
 | ||||||
|  | @ -33,7 +33,7 @@ init-state: | ||||||
| 	$(INSTALL) $(INIT_FLAGS) -d $(DESTDIR)$(localstatedir)/nix/temproots | 	$(INSTALL) $(INIT_FLAGS) -d $(DESTDIR)$(localstatedir)/nix/temproots | ||||||
| 	ln -sfn $(localstatedir)/nix/profiles $(DESTDIR)$(localstatedir)/nix/gcroots/profiles | 	ln -sfn $(localstatedir)/nix/profiles $(DESTDIR)$(localstatedir)/nix/gcroots/profiles | ||||||
| 	$(INSTALL) $(INIT_FLAGS) -d $(DESTDIR)$(localstatedir)/nix/userpool | 	$(INSTALL) $(INIT_FLAGS) -d $(DESTDIR)$(localstatedir)/nix/userpool | ||||||
| 	-$(INSTALL) $(INIT_FLAGS) -m 1777 -d $(DESTDIR)$(storedir) | 	-$(INSTALL) $(INIT_FLAGS) -d $(DESTDIR)$(storedir) | ||||||
| 	$(INSTALL) $(INIT_FLAGS) $(GROUP_WRITABLE) -d $(DESTDIR)$(localstatedir)/nix/manifests | 	$(INSTALL) $(INIT_FLAGS) $(GROUP_WRITABLE) -d $(DESTDIR)$(localstatedir)/nix/manifests | ||||||
| 	ln -sfn $(localstatedir)/nix/manifests $(DESTDIR)$(localstatedir)/nix/gcroots/manifests | 	ln -sfn $(localstatedir)/nix/manifests $(DESTDIR)$(localstatedir)/nix/gcroots/manifests | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -283,6 +283,8 @@ fi | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # Check for the required Perl dependencies (DBI and DBD::SQLite). | # Check for the required Perl dependencies (DBI and DBD::SQLite). | ||||||
|  | perlFlags="-I${libdir}/perl5/site_perl" | ||||||
|  | 
 | ||||||
| AC_ARG_WITH(dbi, AC_HELP_STRING([--with-dbi=PATH], | AC_ARG_WITH(dbi, AC_HELP_STRING([--with-dbi=PATH], | ||||||
|   [prefix of the Perl DBI library]), |   [prefix of the Perl DBI library]), | ||||||
|   perlFlags="$perlFlags -I$withval") |   perlFlags="$perlFlags -I$withval") | ||||||
|  | @ -341,6 +343,7 @@ AC_CONFIG_FILES([Makefile | ||||||
|    src/nix-setuid-helper/Makefile |    src/nix-setuid-helper/Makefile | ||||||
|    src/nix-log2xml/Makefile |    src/nix-log2xml/Makefile | ||||||
|    src/bsdiff-4.3/Makefile |    src/bsdiff-4.3/Makefile | ||||||
|  |    perl/Makefile | ||||||
|    scripts/Makefile |    scripts/Makefile | ||||||
|    corepkgs/Makefile |    corepkgs/Makefile | ||||||
|    corepkgs/nar/Makefile |    corepkgs/nar/Makefile | ||||||
|  |  | ||||||
|  | @ -14,7 +14,7 @@ for ((n = 0; n < ${#inputs[*]}; n += 2)); do | ||||||
|      |      | ||||||
|     echo "unpacking channel $channelName" |     echo "unpacking channel $channelName" | ||||||
|      |      | ||||||
|     @bunzip2@ < $channelTarball | @tar@ xf - |     @bzip2@ -d < $channelTarball | @tar@ xf - | ||||||
| 
 | 
 | ||||||
|     if test -e */channel-name; then |     if test -e */channel-name; then | ||||||
|         channelName="$(@coreutils@/cat */channel-name)" |         channelName="$(@coreutils@/cat */channel-name)" | ||||||
|  |  | ||||||
|  | @ -6,7 +6,7 @@ | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| <para>A number of persistent settings of Nix are stored in the file | <para>A number of persistent settings of Nix are stored in the file | ||||||
| <filename><replaceable>prefix</replaceable>/etc/nix/nix.conf</filename>. | <filename><replaceable>sysconfdir</replaceable>/nix/nix.conf</filename>. | ||||||
| This file is a list of <literal><replaceable>name</replaceable> = | This file is a list of <literal><replaceable>name</replaceable> = | ||||||
| <replaceable>value</replaceable></literal> pairs, one per line. | <replaceable>value</replaceable></literal> pairs, one per line. | ||||||
| Comments start with a <literal>#</literal> character.  An example | Comments start with a <literal>#</literal> character.  An example | ||||||
|  |  | ||||||
|  | @ -314,7 +314,7 @@ bit turned on (like <filename>/tmp</filename>): | ||||||
| 
 | 
 | ||||||
| <screen> | <screen> | ||||||
| $ chgrp nixbld /nix/store | $ chgrp nixbld /nix/store | ||||||
| $ chmod 1777 /nix/store | $ chmod 1775 /nix/store | ||||||
| </screen> | </screen> | ||||||
| 
 | 
 | ||||||
| </para> | </para> | ||||||
|  | @ -323,7 +323,7 @@ $ chmod 1777 /nix/store | ||||||
| specifying the build users group in the <link | specifying the build users group in the <link | ||||||
| linkend="conf-build-users-group"><literal>build-users-group</literal> | linkend="conf-build-users-group"><literal>build-users-group</literal> | ||||||
| option</link> in the <link linkend="sec-conf-file">Nix configuration | option</link> in the <link linkend="sec-conf-file">Nix configuration | ||||||
| file</link> (<literal>/nix/etc/nix/nix.conf</literal>): | file</link> (usually <literal>/etc/nix/nix.conf</literal>): | ||||||
| 
 | 
 | ||||||
| <programlisting> | <programlisting> | ||||||
| build-users-group = nixbld | build-users-group = nixbld | ||||||
|  |  | ||||||
							
								
								
									
										2
									
								
								externals/Makefile.am
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								externals/Makefile.am
									
										
									
									
										vendored
									
									
								
							|  | @ -23,7 +23,7 @@ build-bzip2: $(BZIP2) | ||||||
| 
 | 
 | ||||||
| install-exec-local:: build-bzip2 | install-exec-local:: build-bzip2 | ||||||
| 	mkdir -p $(DESTDIR)${bzip2_bin} | 	mkdir -p $(DESTDIR)${bzip2_bin} | ||||||
| 	$(INSTALL_PROGRAM) $(bzip2_bin_test)/bzip2 $(bzip2_bin_test)/bunzip2 $(DESTDIR)${bzip2_bin} | 	$(INSTALL_PROGRAM) $(bzip2_bin_test)/bzip2 $(DESTDIR)${bzip2_bin} | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -20,6 +20,7 @@ Prefix: /usr | ||||||
| Requires: /usr/bin/perl | Requires: /usr/bin/perl | ||||||
| Requires: curl | Requires: curl | ||||||
| Requires: perl-DBD-SQLite | Requires: perl-DBD-SQLite | ||||||
|  | Requires: perl-devel | ||||||
| 
 | 
 | ||||||
| # Hack to make that shitty RPM scanning hack shut up. | # Hack to make that shitty RPM scanning hack shut up. | ||||||
| Provides: perl(readmanifest) | Provides: perl(readmanifest) | ||||||
|  |  | ||||||
							
								
								
									
										7
									
								
								perl/MANIFEST
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								perl/MANIFEST
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,7 @@ | ||||||
|  | Changes | ||||||
|  | Makefile.PL | ||||||
|  | MANIFEST | ||||||
|  | Nix.xs | ||||||
|  | README | ||||||
|  | t/Nix.t | ||||||
|  | lib/Nix.pm | ||||||
							
								
								
									
										32
									
								
								perl/Makefile.am
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								perl/Makefile.am
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,32 @@ | ||||||
|  | perlversion := $(shell perl -e 'use Config; print $$Config{version};') | ||||||
|  | perlarchname := $(shell perl -e 'use Config; print $$Config{archname};') | ||||||
|  | perllibdir = $(libdir)/perl5/site_perl/$(perlversion)/$(perlarchname) | ||||||
|  | 
 | ||||||
|  | PERL_MODULES = lib/Nix/Store.pm lib/Nix/Manifest.pm lib/Nix/GeneratePatches.pm lib/Nix/SSH.pm lib/Nix/Config.pm.in | ||||||
|  | 
 | ||||||
|  | all: $(PERL_MODULES:.in=) | ||||||
|  | 	ln -sfn $(abs_builddir)/.libs/libNixStore.so lib/Store.so | ||||||
|  | 
 | ||||||
|  | install-exec-local: $(PERL_MODULES:.in=) | ||||||
|  | 	$(INSTALL) -d $(DESTDIR)$(perllibdir)/Nix | ||||||
|  | 	$(INSTALL_DATA) $(PERL_MODULES:.in=) $(DESTDIR)$(perllibdir)/Nix | ||||||
|  | 	$(INSTALL) -d $(DESTDIR)$(perllibdir)/auto/Nix/Store | ||||||
|  | 	ln -sfn $(pkglibdir)/libNixStore.so $(DESTDIR)$(perllibdir)/auto/Nix/Store/Store.so | ||||||
|  | 
 | ||||||
|  | # Awful hackery to get libtool to build Perl XS bindings. | ||||||
|  | pkglib_LTLIBRARIES = libNixStore.la | ||||||
|  | 
 | ||||||
|  | libNixStore_la_SOURCES = lib/Nix/Store.cc | ||||||
|  | 
 | ||||||
|  | libNixStore_la_LIBADD = $(top_srcdir)/src/libstore/libstore.la | ||||||
|  | 
 | ||||||
|  | AM_CXXFLAGS = \ | ||||||
|  |   -I$(top_srcdir)/src -I$(top_srcdir)/src/libutil -I$(top_srcdir)/src/libstore \ | ||||||
|  |   -I$(shell perl -e 'use Config; print $$Config{archlibexp};')/CORE | ||||||
|  | 
 | ||||||
|  | lib/Nix/Store.cc: lib/Nix/Store.xs | ||||||
|  | 	xsubpp $^ -output $@ | ||||||
|  | 
 | ||||||
|  | EXTRA_DIST = $(PERL_MODULES) lib/Nix/Store.xs | ||||||
|  | 
 | ||||||
|  | include ../substitute.mk | ||||||
|  | @ -1,4 +1,12 @@ | ||||||
| use strict; | package Nix::Config; | ||||||
|  | 
 | ||||||
|  | $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; | ||||||
|  | $libexecDir = $ENV{"NIX_LIBEXEC_DIR"} || "@libexecdir@"; | ||||||
|  | $manifestDir = $ENV{"NIX_MANIFESTS_DIR"} || "@localstatedir@/nix/manifests"; | ||||||
|  | $logDir = $ENV{"NIX_LOG_DIR"} || "@localstatedir@/log/nix"; | ||||||
|  | 
 | ||||||
|  | $bzip2 = $ENV{"NIX_BZIP2"} || "@bzip2@"; | ||||||
|  | $curl = "@curl@"; | ||||||
| 
 | 
 | ||||||
| sub readConfig { | sub readConfig { | ||||||
|     my %config; |     my %config; | ||||||
|  | @ -1,6 +1,13 @@ | ||||||
|  | package Nix::GeneratePatches; | ||||||
|  | 
 | ||||||
| use strict; | use strict; | ||||||
| use File::Temp qw(tempdir); | use File::Temp qw(tempdir); | ||||||
| use File::stat; | use File::stat; | ||||||
|  | use Nix::Config; | ||||||
|  | use Nix::Manifest; | ||||||
|  | 
 | ||||||
|  | our @ISA = qw(Exporter); | ||||||
|  | our @EXPORT = qw(generatePatches propagatePatches copyPatches); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # Some patch generations options. | # Some patch generations options. | ||||||
|  | @ -201,7 +208,7 @@ sub generatePatches { | ||||||
|                 next; |                 next; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             system("@bunzip2@ < $srcNarBz2 > $tmpDir/A") == 0 |             system("$Nix::Config::bzip2 -d < $srcNarBz2 > $tmpDir/A") == 0 | ||||||
|                 or die "cannot unpack $srcNarBz2"; |                 or die "cannot unpack $srcNarBz2"; | ||||||
| 
 | 
 | ||||||
|             if (stat("$tmpDir/A")->size >= $maxNarSize) { |             if (stat("$tmpDir/A")->size >= $maxNarSize) { | ||||||
|  | @ -209,7 +216,7 @@ sub generatePatches { | ||||||
|                 next; |                 next; | ||||||
|             } |             } | ||||||
|          |          | ||||||
|             system("@bunzip2@ < $dstNarBz2 > $tmpDir/B") == 0 |             system("$Nix::Config::bzip2 -d < $dstNarBz2 > $tmpDir/B") == 0 | ||||||
|                 or die "cannot unpack $dstNarBz2"; |                 or die "cannot unpack $dstNarBz2"; | ||||||
| 
 | 
 | ||||||
|             if (stat("$tmpDir/B")->size >= $maxNarSize) { |             if (stat("$tmpDir/B")->size >= $maxNarSize) { | ||||||
|  | @ -218,20 +225,20 @@ sub generatePatches { | ||||||
|             } |             } | ||||||
|          |          | ||||||
|             my $time1 = time(); |             my $time1 = time(); | ||||||
|             my $res = system("ulimit -t $timeLimit; @libexecdir@/bsdiff $tmpDir/A $tmpDir/B $tmpDir/DIFF"); |             my $res = system("ulimit -t $timeLimit; $Nix::Config::libexecDir/bsdiff $tmpDir/A $tmpDir/B $tmpDir/DIFF"); | ||||||
|             my $time2 = time(); |             my $time2 = time(); | ||||||
|             if ($res) { |             if ($res) { | ||||||
|                 warn "binary diff computation aborted after ", $time2 - $time1, " seconds\n"; |                 warn "binary diff computation aborted after ", $time2 - $time1, " seconds\n"; | ||||||
|                 next; |                 next; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             my $baseHash = `@bindir@/nix-hash --flat --type $hashAlgo --base32 $tmpDir/A` or die; |             my $baseHash = `$Nix::Config::binDir/nix-hash --flat --type $hashAlgo --base32 $tmpDir/A` or die; | ||||||
|             chomp $baseHash; |             chomp $baseHash; | ||||||
| 
 | 
 | ||||||
|             my $narHash = `@bindir@/nix-hash --flat --type $hashAlgo --base32 $tmpDir/B` or die; |             my $narHash = `$Nix::Config::binDir/nix-hash --flat --type $hashAlgo --base32 $tmpDir/B` or die; | ||||||
|             chomp $narHash; |             chomp $narHash; | ||||||
| 
 | 
 | ||||||
|             my $narDiffHash = `@bindir@/nix-hash --flat --type $hashAlgo --base32 $tmpDir/DIFF` or die; |             my $narDiffHash = `$Nix::Config::binDir/nix-hash --flat --type $hashAlgo --base32 $tmpDir/DIFF` or die; | ||||||
|             chomp $narDiffHash; |             chomp $narDiffHash; | ||||||
| 
 | 
 | ||||||
|             my $narDiffSize = stat("$tmpDir/DIFF")->size; |             my $narDiffSize = stat("$tmpDir/DIFF")->size; | ||||||
|  | @ -1,9 +1,15 @@ | ||||||
|  | package Nix::Manifest; | ||||||
|  | 
 | ||||||
| use strict; | use strict; | ||||||
| use DBI; | use DBI; | ||||||
| use Cwd; | use Cwd; | ||||||
| use File::stat; | use File::stat; | ||||||
| use File::Path; | use File::Path; | ||||||
| use Fcntl ':flock'; | use Fcntl ':flock'; | ||||||
|  | use Nix::Config; | ||||||
|  | 
 | ||||||
|  | our @ISA = qw(Exporter); | ||||||
|  | our @EXPORT = qw(readManifest writeManifest updateManifestDB addPatch); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| sub addNAR { | sub addNAR { | ||||||
|  | @ -200,7 +206,7 @@ sub writeManifest { | ||||||
| 
 | 
 | ||||||
|     # Create a bzipped manifest. |     # Create a bzipped manifest. | ||||||
|     unless (defined $noCompress) { |     unless (defined $noCompress) { | ||||||
| 	system("@bzip2@ < $manifest > $manifest.bz2.tmp") == 0 | 	system("$Nix::Config::bzip2 < $manifest > $manifest.bz2.tmp") == 0 | ||||||
| 	    or die "cannot compress manifest"; | 	    or die "cannot compress manifest"; | ||||||
| 
 | 
 | ||||||
| 	rename("$manifest.bz2.tmp", "$manifest.bz2") | 	rename("$manifest.bz2.tmp", "$manifest.bz2") | ||||||
|  | @ -210,7 +216,7 @@ sub writeManifest { | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| sub updateManifestDB { | sub updateManifestDB { | ||||||
|     my $manifestDir = ($ENV{"NIX_MANIFESTS_DIR"} or "@localstatedir@/nix/manifests"); |     my $manifestDir = $Nix::Config::manifestDir; | ||||||
| 
 | 
 | ||||||
|     mkpath($manifestDir); |     mkpath($manifestDir); | ||||||
|      |      | ||||||
|  | @ -276,7 +282,8 @@ EOF | ||||||
|     # Acquire an exclusive lock to ensure that only one process |     # Acquire an exclusive lock to ensure that only one process | ||||||
|     # updates the DB at the same time.  This isn't really necessary, |     # updates the DB at the same time.  This isn't really necessary, | ||||||
|     # but it prevents work duplication and lock contention in SQLite. |     # but it prevents work duplication and lock contention in SQLite. | ||||||
|     open MAINLOCK, ">>$manifestDir/cache.lock" or die; |     my $lockFile = "$manifestDir/cache.lock"; | ||||||
|  |     open MAINLOCK, ">>$lockFile" or die "unable to acquire lock ‘$lockFile’: $!\n"; | ||||||
|     flock(MAINLOCK, LOCK_EX) or die; |     flock(MAINLOCK, LOCK_EX) or die; | ||||||
| 
 | 
 | ||||||
|     $dbh->begin_work; |     $dbh->begin_work; | ||||||
							
								
								
									
										23
									
								
								perl/lib/Nix/Store.pm
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								perl/lib/Nix/Store.pm
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,23 @@ | ||||||
|  | package Nix::Store; | ||||||
|  | 
 | ||||||
|  | use 5.010001; | ||||||
|  | use strict; | ||||||
|  | use warnings; | ||||||
|  | 
 | ||||||
|  | require Exporter; | ||||||
|  | 
 | ||||||
|  | our @ISA = qw(Exporter); | ||||||
|  | 
 | ||||||
|  | our %EXPORT_TAGS = ( 'all' => [ qw( ) ] ); | ||||||
|  | 
 | ||||||
|  | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | ||||||
|  | 
 | ||||||
|  | our @EXPORT = qw(isValidPath topoSortPaths computeFSClosure followLinksToStorePath); | ||||||
|  | 
 | ||||||
|  | our $VERSION = '0.15'; | ||||||
|  | 
 | ||||||
|  | require XSLoader; | ||||||
|  | XSLoader::load('Nix::Store', $VERSION); | ||||||
|  | 
 | ||||||
|  | 1; | ||||||
|  | __END__ | ||||||
							
								
								
									
										150
									
								
								perl/lib/Nix/Store.xs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										150
									
								
								perl/lib/Nix/Store.xs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,150 @@ | ||||||
|  | #include "EXTERN.h" | ||||||
|  | #include "perl.h" | ||||||
|  | #include "XSUB.h" | ||||||
|  | 
 | ||||||
|  | /* Prevent a clash between some Perl and libstdc++ macros. */ | ||||||
|  | #undef do_open | ||||||
|  | #undef do_close | ||||||
|  | 
 | ||||||
|  | #include <store-api.hh> | ||||||
|  | #include <globals.hh> | ||||||
|  | #include <misc.hh> | ||||||
|  | #include <util.hh> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | using namespace nix; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | void doInit()  | ||||||
|  | { | ||||||
|  |     if (!store) { | ||||||
|  |         nixStore = canonPath(getEnv("NIX_STORE_DIR", getEnv("NIX_STORE", "/nix/store"))); | ||||||
|  |         nixStateDir = canonPath(getEnv("NIX_STATE_DIR", "/nix/var/nix")); | ||||||
|  |         nixDBPath = getEnv("NIX_DB_DIR", nixStateDir + "/db"); | ||||||
|  |         try { | ||||||
|  |             store = openStore(); | ||||||
|  |         } catch (Error & e) { | ||||||
|  |             croak(e.what()); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | MODULE = Nix::Store PACKAGE = Nix::Store | ||||||
|  | PROTOTYPES: ENABLE | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | void init() | ||||||
|  |     CODE: | ||||||
|  |         doInit(); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | int isValidPath(char * path) | ||||||
|  |     CODE: | ||||||
|  |         try { | ||||||
|  |             doInit(); | ||||||
|  |             RETVAL = store->isValidPath(path); | ||||||
|  |         } catch (Error & e) { | ||||||
|  |             croak(e.what()); | ||||||
|  |         } | ||||||
|  |     OUTPUT: | ||||||
|  |         RETVAL | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | SV * queryReferences(char * path) | ||||||
|  |     PPCODE: | ||||||
|  |         try { | ||||||
|  |             doInit(); | ||||||
|  |             PathSet paths; | ||||||
|  |             store->queryReferences(path, paths); | ||||||
|  |             for (PathSet::iterator i = paths.begin(); i != paths.end(); ++i) | ||||||
|  |                 XPUSHs(sv_2mortal(newSVpv(i->c_str(), 0))); | ||||||
|  |         } catch (Error & e) { | ||||||
|  |             croak(e.what()); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | SV * queryPathHash(char * path) | ||||||
|  |     PPCODE: | ||||||
|  |         try { | ||||||
|  |             doInit(); | ||||||
|  |             Hash hash = store->queryPathHash(path); | ||||||
|  |             string s = "sha256:" + printHash(hash); | ||||||
|  |             XPUSHs(sv_2mortal(newSVpv(s.c_str(), 0))); | ||||||
|  |         } catch (Error & e) { | ||||||
|  |             croak(e.what()); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | SV * queryDeriver(char * path) | ||||||
|  |     PPCODE: | ||||||
|  |         try { | ||||||
|  |             doInit(); | ||||||
|  |             Path deriver = store->queryDeriver(path); | ||||||
|  |             if (deriver == "") XSRETURN_UNDEF; | ||||||
|  |             XPUSHs(sv_2mortal(newSVpv(deriver.c_str(), 0))); | ||||||
|  |         } catch (Error & e) { | ||||||
|  |             croak(e.what()); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | SV * queryPathInfo(char * path) | ||||||
|  |     PPCODE: | ||||||
|  |         try { | ||||||
|  |             doInit(); | ||||||
|  |             ValidPathInfo info = store->queryPathInfo(path); | ||||||
|  |             if (info.deriver == "") | ||||||
|  |                 XPUSHs(&PL_sv_undef); | ||||||
|  |             else | ||||||
|  |                 XPUSHs(sv_2mortal(newSVpv(info.deriver.c_str(), 0))); | ||||||
|  |             string s = "sha256:" + printHash(info.hash); | ||||||
|  |             XPUSHs(sv_2mortal(newSVpv(s.c_str(), 0))); | ||||||
|  |             mXPUSHi(info.registrationTime); | ||||||
|  |             mXPUSHi(info.narSize); | ||||||
|  |             AV * arr = newAV(); | ||||||
|  |             for (PathSet::iterator i = info.references.begin(); i != info.references.end(); ++i) | ||||||
|  |                 av_push(arr, newSVpv(i->c_str(), 0)); | ||||||
|  |             XPUSHs(sv_2mortal(newRV((SV *) arr))); | ||||||
|  |         } catch (Error & e) { | ||||||
|  |             croak(e.what()); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | SV * computeFSClosure(int flipDirection, int includeOutputs, ...) | ||||||
|  |     PPCODE: | ||||||
|  |         try { | ||||||
|  |             doInit(); | ||||||
|  |             PathSet paths; | ||||||
|  |             for (int n = 2; n < items; ++n) | ||||||
|  |                 computeFSClosure(*store, SvPV_nolen(ST(n)), paths, flipDirection, includeOutputs); | ||||||
|  |             for (PathSet::iterator i = paths.begin(); i != paths.end(); ++i) | ||||||
|  |                 XPUSHs(sv_2mortal(newSVpv(i->c_str(), 0))); | ||||||
|  |         } catch (Error & e) { | ||||||
|  |             croak(e.what()); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | SV * topoSortPaths(...) | ||||||
|  |     PPCODE: | ||||||
|  |         try { | ||||||
|  |             doInit(); | ||||||
|  |             PathSet paths; | ||||||
|  |             for (int n = 0; n < items; ++n) paths.insert(SvPV_nolen(ST(n))); | ||||||
|  |             Paths sorted = topoSortPaths(*store, paths); | ||||||
|  |             for (Paths::iterator i = sorted.begin(); i != sorted.end(); ++i) | ||||||
|  |                 XPUSHs(sv_2mortal(newSVpv(i->c_str(), 0))); | ||||||
|  |         } catch (Error & e) { | ||||||
|  |             croak(e.what()); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | SV * followLinksToStorePath(char * path) | ||||||
|  |     CODE: | ||||||
|  |         try { | ||||||
|  |             doInit(); | ||||||
|  |             RETVAL = newSVpv(followLinksToStorePath(path).c_str(), 0); | ||||||
|  |         } catch (Error & e) { | ||||||
|  |             croak(e.what()); | ||||||
|  |         } | ||||||
|  |     OUTPUT: | ||||||
|  |         RETVAL | ||||||
							
								
								
									
										15
									
								
								release.nix
									
										
									
									
									
								
							
							
						
						
									
										15
									
								
								release.nix
									
										
									
									
									
								
							|  | @ -1,5 +1,5 @@ | ||||||
| { nixpkgs ? ../nixpkgs | { nixpkgs ? <nixpkgs>, nixos ? <nixos> | ||||||
| , nix ? { outPath = ./.; rev = 1234; } | , nix ? { outPath = ../nix-export; rev = 1234; } | ||||||
| , officialRelease ? false | , officialRelease ? false | ||||||
| }: | }: | ||||||
| 
 | 
 | ||||||
|  | @ -140,6 +140,15 @@ let | ||||||
|     deb_ubuntu1010x86_64 = makeDeb_x86_64 (diskImageFuns: diskImageFuns.ubuntu1010x86_64) 50; |     deb_ubuntu1010x86_64 = makeDeb_x86_64 (diskImageFuns: diskImageFuns.ubuntu1010x86_64) 50; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |     # System tests. | ||||||
|  |     tests.remote_builds = (import ./tests/remote-builds.nix rec { | ||||||
|  |       inherit nixpkgs nixos; nix = build { inherit system; }; system = "x86_64-linux"; | ||||||
|  |     }).test; | ||||||
|  | 
 | ||||||
|  |     tests.nix_copy_closure = (import ./tests/nix-copy-closure.nix rec { | ||||||
|  |       inherit nixpkgs nixos; nix = build { inherit system; }; system = "x86_64-linux"; | ||||||
|  |     }).test; | ||||||
|  | 
 | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -155,7 +164,7 @@ let | ||||||
|       name = "nix-rpm-${diskImage.name}"; |       name = "nix-rpm-${diskImage.name}"; | ||||||
|       src = jobs.tarball; |       src = jobs.tarball; | ||||||
|       diskImage = (diskImageFun vmTools.diskImageFuns) |       diskImage = (diskImageFun vmTools.diskImageFuns) | ||||||
|         { extraPackages = [ "perl-DBD-SQLite" ]; }; |         { extraPackages = [ "perl-DBD-SQLite" "perl-devel" ]; }; | ||||||
|       memSize = 1024; |       memSize = 1024; | ||||||
|       meta.schedulingPriority = prio; |       meta.schedulingPriority = prio; | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -3,20 +3,16 @@ bin_SCRIPTS = nix-collect-garbage \ | ||||||
|   nix-install-package nix-channel nix-build \ |   nix-install-package nix-channel nix-build \ | ||||||
|   nix-copy-closure nix-generate-patches |   nix-copy-closure nix-generate-patches | ||||||
| 
 | 
 | ||||||
| noinst_SCRIPTS = nix-profile.sh GeneratePatches.pm \ | noinst_SCRIPTS = nix-profile.sh \ | ||||||
|   find-runtime-roots.pl build-remote.pl nix-reduce-build \ |   find-runtime-roots.pl build-remote.pl nix-reduce-build \ | ||||||
|   copy-from-other-stores.pl nix-http-export.cgi |   copy-from-other-stores.pl nix-http-export.cgi | ||||||
| 
 | 
 | ||||||
| nix-pull nix-push: NixManifest.pm NixConfig.pm download-using-manifests.pl | nix-pull nix-push: download-using-manifests.pl | ||||||
| 
 | 
 | ||||||
| install-exec-local: NixManifest.pm GeneratePatches.pm download-using-manifests.pl copy-from-other-stores.pl find-runtime-roots.pl | install-exec-local: download-using-manifests.pl copy-from-other-stores.pl find-runtime-roots.pl | ||||||
| 	$(INSTALL) -d $(DESTDIR)$(sysconfdir)/profile.d | 	$(INSTALL) -d $(DESTDIR)$(sysconfdir)/profile.d | ||||||
| 	$(INSTALL_PROGRAM) nix-profile.sh $(DESTDIR)$(sysconfdir)/profile.d/nix.sh | 	$(INSTALL_PROGRAM) nix-profile.sh $(DESTDIR)$(sysconfdir)/profile.d/nix.sh | ||||||
| 	$(INSTALL) -d $(DESTDIR)$(libexecdir)/nix | 	$(INSTALL) -d $(DESTDIR)$(libexecdir)/nix | ||||||
| 	$(INSTALL_DATA) NixManifest.pm $(DESTDIR)$(libexecdir)/nix  |  | ||||||
| 	$(INSTALL_DATA) NixConfig.pm $(DESTDIR)$(libexecdir)/nix  |  | ||||||
| 	$(INSTALL_DATA) SSH.pm $(DESTDIR)$(libexecdir)/nix  |  | ||||||
| 	$(INSTALL_DATA) GeneratePatches.pm $(DESTDIR)$(libexecdir)/nix  |  | ||||||
| 	$(INSTALL_PROGRAM) find-runtime-roots.pl $(DESTDIR)$(libexecdir)/nix  | 	$(INSTALL_PROGRAM) find-runtime-roots.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) -d $(DESTDIR)$(libexecdir)/nix/substituters | ||||||
|  | @ -30,10 +26,6 @@ EXTRA_DIST = nix-collect-garbage.in \ | ||||||
|   nix-pull.in nix-push.in nix-profile.sh.in \ |   nix-pull.in nix-push.in nix-profile.sh.in \ | ||||||
|   nix-prefetch-url.in nix-install-package.in \ |   nix-prefetch-url.in nix-install-package.in \ | ||||||
|   nix-channel.in \ |   nix-channel.in \ | ||||||
|   NixManifest.pm.in \ |  | ||||||
|   NixConfig.pm.in \ |  | ||||||
|   SSH.pm \ |  | ||||||
|   GeneratePatches.pm.in \ |  | ||||||
|   nix-build.in \ |   nix-build.in \ | ||||||
|   download-using-manifests.pl.in \ |   download-using-manifests.pl.in \ | ||||||
|   copy-from-other-stores.pl.in \ |   copy-from-other-stores.pl.in \ | ||||||
|  | @ -43,3 +35,6 @@ EXTRA_DIST = nix-collect-garbage.in \ | ||||||
|   nix-reduce-build.in \ |   nix-reduce-build.in \ | ||||||
|   nix-http-export.cgi.in \ |   nix-http-export.cgi.in \ | ||||||
|   nix-generate-patches.in |   nix-generate-patches.in | ||||||
|  | 
 | ||||||
|  | clean: | ||||||
|  | 	rm -f $(bin_SCRIPTS) $(noinst_SCRIPTS) | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| #! @perl@ -w -I@libexecdir@/nix | #! @perl@ -w @perlFlags@ | ||||||
| 
 | 
 | ||||||
| use Fcntl ':flock'; | use Fcntl ':flock'; | ||||||
| use English '-no_match_vars'; | use English '-no_match_vars'; | ||||||
| use IO::Handle; | use IO::Handle; | ||||||
| use SSH qw/sshOpts openSSHConnection/; | use Nix::SSH qw/sshOpts openSSHConnection/; | ||||||
| no warnings('once'); | no warnings('once'); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										0
									
								
								scripts/copy-from-other-stores.pl.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								scripts/copy-from-other-stores.pl.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										30
									
								
								scripts/download-using-manifests.pl.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										30
									
								
								scripts/download-using-manifests.pl.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							|  | @ -1,16 +1,14 @@ | ||||||
| #! @perl@ -w -I@libexecdir@/nix @perlFlags@ | #! @perl@ -w @perlFlags@ | ||||||
| 
 | 
 | ||||||
| use strict; | use strict; | ||||||
| use NixManifest; | use Nix::Config; | ||||||
|  | use Nix::Manifest; | ||||||
| use POSIX qw(strftime); | use POSIX qw(strftime); | ||||||
| use File::Temp qw(tempdir); | use File::Temp qw(tempdir); | ||||||
| 
 | 
 | ||||||
| my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; |  | ||||||
| 
 |  | ||||||
| STDOUT->autoflush(1); | STDOUT->autoflush(1); | ||||||
| 
 | 
 | ||||||
| my $manifestDir = ($ENV{"NIX_MANIFESTS_DIR"} or "@localstatedir@/nix/manifests"); | my $logFile = "$Nix::Config::logDir/downloads"; | ||||||
| my $logFile = "@localstatedir@/log/nix/downloads"; |  | ||||||
| 
 | 
 | ||||||
| # For queries, skip expensive calls to nix-hash etc.  We're just | # For queries, skip expensive calls to nix-hash etc.  We're just | ||||||
| # estimating the expected download size. | # estimating the expected download size. | ||||||
|  | @ -26,7 +24,7 @@ sub isValidPath { | ||||||
|     if ($fast) { |     if ($fast) { | ||||||
|         return -e $p; |         return -e $p; | ||||||
|     } else { |     } else { | ||||||
|         return system("$binDir/nix-store --check-validity '$p' 2> /dev/null") == 0; |         return system("$Nix::Config::binDir/nix-store --check-validity '$p' 2> /dev/null") == 0; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -108,8 +106,8 @@ sub computeSmallestDownload { | ||||||
|                     my $format = "--base32"; |                     my $format = "--base32"; | ||||||
|                     $format = "" if $baseHashAlgo eq "md5"; |                     $format = "" if $baseHashAlgo eq "md5"; | ||||||
|                     my $hash = $fast && $baseHashAlgo eq "sha256" |                     my $hash = $fast && $baseHashAlgo eq "sha256" | ||||||
|                         ? `$binDir/nix-store -q --hash "$patch->{basePath}"` |                         ? `$Nix::Config::binDir/nix-store -q --hash "$patch->{basePath}"` | ||||||
|                         : `$binDir/nix-hash --type '$baseHashAlgo' $format "$patch->{basePath}"`; |                         : `$Nix::Config::binDir/nix-hash --type '$baseHashAlgo' $format "$patch->{basePath}"`; | ||||||
|                     chomp $hash; |                     chomp $hash; | ||||||
|                     $hash =~ s/.*://; |                     $hash =~ s/.*://; | ||||||
|                     next if $hash ne $baseHash; |                     next if $hash ne $baseHash; | ||||||
|  | @ -282,7 +280,7 @@ sub downloadFile { | ||||||
|     my $url = shift;  |     my $url = shift;  | ||||||
|     $ENV{"PRINT_PATH"} = 1; |     $ENV{"PRINT_PATH"} = 1; | ||||||
|     $ENV{"QUIET"} = 1; |     $ENV{"QUIET"} = 1; | ||||||
|     my ($hash, $path) = `$binDir/nix-prefetch-url '$url'`; |     my ($hash, $path) = `$Nix::Config::binDir/nix-prefetch-url '$url'`; | ||||||
|     die "download of `$url' failed" . ($! ? ": $!" : "") unless $? == 0; |     die "download of `$url' failed" . ($! ? ": $!" : "") unless $? == 0; | ||||||
|     chomp $path; |     chomp $path; | ||||||
|     return $path; |     return $path; | ||||||
|  | @ -306,7 +304,7 @@ while (scalar @path > 0) { | ||||||
|             # as a base to one or more patches.  So turn the base path |             # as a base to one or more patches.  So turn the base path | ||||||
|             # into a NAR archive, to which we can apply the patch. |             # into a NAR archive, to which we can apply the patch. | ||||||
|             print "  packing base path...\n"; |             print "  packing base path...\n"; | ||||||
|             system("$binDir/nix-store --dump $v > $tmpNar") == 0 |             system("$Nix::Config::binDir/nix-store --dump $v > $tmpNar") == 0 | ||||||
|                 or die "cannot dump `$v'"; |                 or die "cannot dump `$v'"; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | @ -324,7 +322,7 @@ while (scalar @path > 0) { | ||||||
|         # Apply the patch to the NAR archive produced in step 1 (for |         # Apply the patch to the NAR archive produced in step 1 (for | ||||||
|         # the already present path) or a later step (for patch sequences). |         # the already present path) or a later step (for patch sequences). | ||||||
|         print "  applying patch...\n"; |         print "  applying patch...\n"; | ||||||
|         system("@libexecdir@/bspatch $tmpNar $tmpNar2 $patchPath") == 0 |         system("$Nix::Config::libexecDir/bspatch $tmpNar $tmpNar2 $patchPath") == 0 | ||||||
|             or die "cannot apply patch `$patchPath' to $tmpNar"; |             or die "cannot apply patch `$patchPath' to $tmpNar"; | ||||||
| 
 | 
 | ||||||
|         if ($curStep < $maxStep) { |         if ($curStep < $maxStep) { | ||||||
|  | @ -334,7 +332,7 @@ while (scalar @path > 0) { | ||||||
|             # This was the last patch.  Unpack the final NAR archive |             # This was the last patch.  Unpack the final NAR archive | ||||||
|             # into the target path. |             # into the target path. | ||||||
|             print "  unpacking patched archive...\n"; |             print "  unpacking patched archive...\n"; | ||||||
|             system("$binDir/nix-store --restore $v < $tmpNar2") == 0 |             system("$Nix::Config::binDir/nix-store --restore $v < $tmpNar2") == 0 | ||||||
|                 or die "cannot unpack $tmpNar2 into `$v'"; |                 or die "cannot unpack $tmpNar2 into `$v'"; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | @ -354,12 +352,12 @@ while (scalar @path > 0) { | ||||||
| 
 | 
 | ||||||
|         if ($curStep < $maxStep) { |         if ($curStep < $maxStep) { | ||||||
|             # The archive will be used a base to a patch. |             # The archive will be used a base to a patch. | ||||||
|             system("@bunzip2@ < '$narFilePath' > $tmpNar") == 0 |             system("$Nix::Config::bzip2 -d < '$narFilePath' > $tmpNar") == 0 | ||||||
|                 or die "cannot unpack `$narFilePath' into `$v'"; |                 or die "cannot unpack `$narFilePath' into `$v'"; | ||||||
|         } else { |         } else { | ||||||
|             # Unpack the archive into the target path. |             # Unpack the archive into the target path. | ||||||
|             print "  unpacking archive...\n"; |             print "  unpacking archive...\n"; | ||||||
|             system("@bunzip2@ < '$narFilePath' | $binDir/nix-store --restore '$v'") == 0 |             system("$Nix::Config::bzip2 -d < '$narFilePath' | $Nix::Config::binDir/nix-store --restore '$v'") == 0 | ||||||
|                 or die "cannot unpack `$narFilePath' into `$v'"; |                 or die "cannot unpack `$narFilePath' into `$v'"; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | @ -382,7 +380,7 @@ if (defined $finalNarHash) { | ||||||
|         ($hashAlgo eq "sha256" && length($hash) != 64) |         ($hashAlgo eq "sha256" && length($hash) != 64) | ||||||
|         ? "--base32" : ""; |         ? "--base32" : ""; | ||||||
|      |      | ||||||
|     my $hash2 = `@bindir@/nix-hash --type $hashAlgo $extraFlag $targetPath` |     my $hash2 = `$Nix::Config::binDir/nix-hash --type $hashAlgo $extraFlag $targetPath` | ||||||
|         or die "cannot compute hash of path `$targetPath'"; |         or die "cannot compute hash of path `$targetPath'"; | ||||||
|     chomp $hash2; |     chomp $hash2; | ||||||
|      |      | ||||||
|  |  | ||||||
							
								
								
									
										0
									
								
								scripts/find-runtime-roots.pl.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								scripts/find-runtime-roots.pl.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										0
									
								
								scripts/nix-build.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								scripts/nix-build.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										0
									
								
								scripts/nix-channel.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								scripts/nix-channel.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										0
									
								
								scripts/nix-collect-garbage.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								scripts/nix-collect-garbage.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										63
									
								
								scripts/nix-copy-closure.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										63
									
								
								scripts/nix-copy-closure.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							|  | @ -1,8 +1,8 @@ | ||||||
| #! @perl@ -w -I@libexecdir@/nix | #! @perl@ -w @perlFlags@ | ||||||
| 
 | 
 | ||||||
| use SSH; | use Nix::SSH; | ||||||
| 
 | use Nix::Config; | ||||||
| my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; | use Nix::Store; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| if (scalar @ARGV < 1) { | if (scalar @ARGV < 1) { | ||||||
|  | @ -24,6 +24,10 @@ my $decompressor = ""; | ||||||
| 
 | 
 | ||||||
| my $toMode = 1; | my $toMode = 1; | ||||||
| 
 | 
 | ||||||
|  | my $includeOutputs = 0; | ||||||
|  | 
 | ||||||
|  | my $dryRun = 0; | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| # !!! Copied from nix-pack-closure, should put this in a module. | # !!! Copied from nix-pack-closure, should put this in a module. | ||||||
| my @storePaths = (); | my @storePaths = (); | ||||||
|  | @ -44,6 +48,12 @@ while (@ARGV) { | ||||||
|     elsif ($arg eq "--to") { |     elsif ($arg eq "--to") { | ||||||
|         $toMode = 1; |         $toMode = 1; | ||||||
|     } |     } | ||||||
|  |     elsif ($arg eq "--include-outputs") { | ||||||
|  |         $includeOutputs = 1; | ||||||
|  |     } | ||||||
|  |     elsif ($arg eq "--dry-run") { | ||||||
|  |         $dryRun = 1; | ||||||
|  |     } | ||||||
|     elsif (!defined $sshHost) { |     elsif (!defined $sshHost) { | ||||||
|         $sshHost = $arg; |         $sshHost = $arg; | ||||||
|     } |     } | ||||||
|  | @ -58,19 +68,8 @@ openSSHConnection $sshHost or die "$0: unable to start SSH\n"; | ||||||
| 
 | 
 | ||||||
| if ($toMode) { # Copy TO the remote machine. | if ($toMode) { # Copy TO the remote machine. | ||||||
| 
 | 
 | ||||||
|     my @allStorePaths; |  | ||||||
| 
 |  | ||||||
|     # Get the closure of this path. |     # Get the closure of this path. | ||||||
|     my $pid = open(READ, "set -f; $binDir/nix-store --query --requisites @storePaths|") or die; |     my @allStorePaths = reverse(topoSortPaths(computeFSClosure(0, $includeOutputs, map { followLinksToStorePath $_ } @storePaths))); | ||||||
|      |  | ||||||
|     while (<READ>) { |  | ||||||
|         chomp; |  | ||||||
|         die "bad: $_" unless /^\//; |  | ||||||
|         push @allStorePaths, $_; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     close READ or die "nix-store failed: $?"; |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
|     # Ask the remote host which paths are invalid. |     # Ask the remote host which paths are invalid. | ||||||
|     open(READ, "set -f; ssh $sshHost @sshOpts nix-store --check-validity --print-invalid @allStorePaths|"); |     open(READ, "set -f; ssh $sshHost @sshOpts nix-store --check-validity --print-invalid @allStorePaths|"); | ||||||
|  | @ -81,57 +80,45 @@ if ($toMode) { # Copy TO the remote machine. | ||||||
|     } |     } | ||||||
|     close READ or die; |     close READ or die; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     # Export the store paths and import them on the remote machine. |     # Export the store paths and import them on the remote machine. | ||||||
|     if (scalar @missing > 0) { |     if (scalar @missing > 0) { | ||||||
|         print STDERR "copying these missing paths:\n"; |         print STDERR "copying these missing paths:\n"; | ||||||
|         print STDERR "  $_\n" foreach @missing; |         print STDERR "  $_\n" foreach @missing; | ||||||
|         my $extraOpts = ""; |         unless ($dryRun) { | ||||||
|         $extraOpts .= "--sign" if $sign == 1; |             my $extraOpts = $sign ? "--sign" : ""; | ||||||
|             system("set -f; nix-store --export $extraOpts @missing $compressor | ssh $sshHost @sshOpts '$decompressor nix-store --import'") == 0 |             system("set -f; nix-store --export $extraOpts @missing $compressor | ssh $sshHost @sshOpts '$decompressor nix-store --import'") == 0 | ||||||
|                 or die "copying store paths to remote machine `$sshHost' failed: $?"; |                 or die "copying store paths to remote machine `$sshHost' failed: $?"; | ||||||
|         } |         } | ||||||
| 
 |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| else { # Copy FROM the remote machine. | else { # Copy FROM the remote machine. | ||||||
| 
 | 
 | ||||||
|     # Query the closure of the given store paths on the remote |     # Query the closure of the given store paths on the remote | ||||||
|     # machine.  Paths are assumed to be store paths; there is no |     # machine.  Paths are assumed to be store paths; there is no | ||||||
|     # resolution (following of symlinks). |     # resolution (following of symlinks). | ||||||
|  |     my $extraOpts = $includeOutputs ? "--include-outputs" : ""; | ||||||
|     my $pid = open(READ, |     my $pid = open(READ, | ||||||
|         "set -f; ssh @sshOpts $sshHost nix-store --query --requisites @storePaths|") or die; |         "set -f; ssh @sshOpts $sshHost nix-store --query --requisites $extraOpts @storePaths|") or die; | ||||||
|      |  | ||||||
|     my @allStorePaths; |  | ||||||
|      |      | ||||||
|     while (<READ>) { |     while (<READ>) { | ||||||
|         chomp; |         chomp; | ||||||
|         die "bad: $_" unless /^\//; |         die "bad: $_" unless /^\//; | ||||||
|         push @allStorePaths, $_; |         push @missing, $_ unless isValidPath($_); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     close READ or die "nix-store on remote machine `$sshHost' failed: $?"; |     close READ or die "nix-store on remote machine `$sshHost' failed: $?"; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     # What paths are already valid locally? |  | ||||||
|     open(READ, "set -f; @bindir@/nix-store --check-validity --print-invalid @allStorePaths|"); |  | ||||||
|     my @missing = (); |  | ||||||
|     while (<READ>) { |  | ||||||
|         chomp; |  | ||||||
|         push @missing, $_; |  | ||||||
|     } |  | ||||||
|     close READ or die; |  | ||||||
|      |  | ||||||
| 
 |  | ||||||
|     # Export the store paths on the remote machine and import them on locally. |     # Export the store paths on the remote machine and import them on locally. | ||||||
|     if (scalar @missing > 0) { |     if (scalar @missing > 0) { | ||||||
|         print STDERR "copying these missing paths:\n"; |         print STDERR "copying these missing paths:\n"; | ||||||
|         print STDERR "  $_\n" foreach @missing; |         print STDERR "  $_\n" foreach @missing; | ||||||
|         my $extraOpts = ""; |         unless ($dryRun) { | ||||||
|         $extraOpts .= "--sign" if $sign == 1; |             my $extraOpts = $sign ? "--sign" : ""; | ||||||
|         system("set -f; ssh $sshHost @sshOpts 'nix-store --export $extraOpts @missing $compressor' | $decompressor @bindir@/nix-store --import") == 0 |             system("set -f; ssh $sshHost @sshOpts 'nix-store --export $extraOpts @missing $compressor' | $decompressor $Nix::Config::binDir/nix-store --import") == 0 | ||||||
|                 or die "copying store paths from remote machine `$sshHost' failed: $?"; |                 or die "copying store paths from remote machine `$sshHost' failed: $?"; | ||||||
|         } |         } | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										6
									
								
								scripts/nix-generate-patches.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										6
									
								
								scripts/nix-generate-patches.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							|  | @ -1,9 +1,9 @@ | ||||||
| #! @perl@ -w -I@libexecdir@/nix @perlFlags@ | #! @perl@ -w @perlFlags@ | ||||||
| 
 | 
 | ||||||
| use strict; | use strict; | ||||||
| use File::Temp qw(tempdir); | use File::Temp qw(tempdir); | ||||||
| use NixManifest; | use Nix::Manifest; | ||||||
| use GeneratePatches; | use Nix::GeneratePatches; | ||||||
| 
 | 
 | ||||||
| if (scalar @ARGV != 5) { | if (scalar @ARGV != 5) { | ||||||
|     print STDERR <<EOF; |     print STDERR <<EOF; | ||||||
|  |  | ||||||
							
								
								
									
										9
									
								
								scripts/nix-install-package.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										9
									
								
								scripts/nix-install-package.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							|  | @ -2,8 +2,7 @@ | ||||||
| 
 | 
 | ||||||
| use strict; | use strict; | ||||||
| use File::Temp qw(tempdir); | use File::Temp qw(tempdir); | ||||||
| 
 | use Nix::Config; | ||||||
| my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| sub usageError { | sub usageError { | ||||||
|  | @ -61,7 +60,7 @@ if ($interactive && !defined $ENV{"NIX_HAVE_TERMINAL"}) { | ||||||
|     $ENV{"NIX_HAVE_TERMINAL"} = "1"; |     $ENV{"NIX_HAVE_TERMINAL"} = "1"; | ||||||
|     $ENV{"LD_LIBRARY_PATH"} = ""; |     $ENV{"LD_LIBRARY_PATH"} = ""; | ||||||
|     foreach my $term ("xterm", "konsole", "gnome-terminal", "xterm") { |     foreach my $term ("xterm", "konsole", "gnome-terminal", "xterm") { | ||||||
|         exec($term, "-e", "$binDir/nix-install-package", @ARGV); |         exec($term, "-e", "$Nix::Config::binDir/nix-install-package", @ARGV); | ||||||
|     } |     } | ||||||
|     die "cannot execute `xterm'"; |     die "cannot execute `xterm'"; | ||||||
| } | } | ||||||
|  | @ -132,12 +131,12 @@ $ENV{NIX_REMOTE} = ""; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| print "\nPulling manifests...\n"; | print "\nPulling manifests...\n"; | ||||||
| system("$binDir/nix-pull", $manifestURL) == 0 | system("$Nix::Config::binDir/nix-pull", $manifestURL) == 0 | ||||||
|     or barf "nix-pull failed: $?"; |     or barf "nix-pull failed: $?"; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| print "\nInstalling package...\n"; | print "\nInstalling package...\n"; | ||||||
| system("$binDir/nix-env", "--install", $outPath, "--force-name", $drvName, @extraNixEnvArgs) == 0 | system("$Nix::Config::binDir/nix-env", "--install", $outPath, "--force-name", $drvName, @extraNixEnvArgs) == 0 | ||||||
|     or barf "nix-env failed: $?"; |     or barf "nix-env failed: $?"; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										17
									
								
								scripts/nix-prefetch-url.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										17
									
								
								scripts/nix-prefetch-url.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							|  | @ -3,6 +3,9 @@ | ||||||
| url=$1 | url=$1 | ||||||
| expHash=$2 | expHash=$2 | ||||||
| 
 | 
 | ||||||
|  | binDir=@bindir@ | ||||||
|  | if [ -n "$NIX_BIN_DIR" ]; then binDir="$NIX_BIN_DIR"; fi | ||||||
|  | 
 | ||||||
| # needed to make it work on NixOS | # needed to make it work on NixOS | ||||||
| export PATH=$PATH:@coreutils@ | export PATH=$PATH:@coreutils@ | ||||||
| 
 | 
 | ||||||
|  | @ -31,8 +34,8 @@ if test -z "$name"; then echo "invalid url"; exit 1; fi | ||||||
| # If the hash was given, a file with that hash may already be in the | # If the hash was given, a file with that hash may already be in the | ||||||
| # store. | # store. | ||||||
| if test -n "$expHash"; then | if test -n "$expHash"; then | ||||||
|     finalPath=$(@bindir@/nix-store --print-fixed-path "$hashType" "$expHash" "$name") |     finalPath=$($binDir/nix-store --print-fixed-path "$hashType" "$expHash" "$name") | ||||||
|     if ! @bindir@/nix-store --check-validity "$finalPath" 2> /dev/null; then |     if ! $bindir/nix-store --check-validity "$finalPath" 2> /dev/null; then | ||||||
|         finalPath= |         finalPath= | ||||||
|     fi |     fi | ||||||
|     hash=$expHash |     hash=$expHash | ||||||
|  | @ -103,7 +106,7 @@ if test -z "$finalPath"; then | ||||||
|     # garbage-collected independently. |     # garbage-collected independently. | ||||||
|     if test -n "$NIX_DOWNLOAD_CACHE"; then |     if test -n "$NIX_DOWNLOAD_CACHE"; then | ||||||
|         echo -n "$url" > $tmpPath/url |         echo -n "$url" > $tmpPath/url | ||||||
|         urlHash=$(@bindir@/nix-hash --type sha256 --base32 --flat $tmpPath/url) |         urlHash=$($binDir/nix-hash --type sha256 --base32 --flat $tmpPath/url) | ||||||
|         echo "$url" > "$NIX_DOWNLOAD_CACHE/$urlHash.url" |         echo "$url" > "$NIX_DOWNLOAD_CACHE/$urlHash.url" | ||||||
|         cachedHashFN="$NIX_DOWNLOAD_CACHE/$urlHash.$hashType" |         cachedHashFN="$NIX_DOWNLOAD_CACHE/$urlHash.$hashType" | ||||||
|         cachedTimestampFN="$NIX_DOWNLOAD_CACHE/$urlHash.stamp" |         cachedTimestampFN="$NIX_DOWNLOAD_CACHE/$urlHash.stamp" | ||||||
|  | @ -121,8 +124,8 @@ if test -z "$finalPath"; then | ||||||
|         # Curl didn't create $tmpFile, so apparently there's no newer |         # Curl didn't create $tmpFile, so apparently there's no newer | ||||||
|         # file on the server. |         # file on the server. | ||||||
|         hash=$(cat $cachedHashFN) |         hash=$(cat $cachedHashFN) | ||||||
|         finalPath=$(@bindir@/nix-store --print-fixed-path "$hashType" "$hash" "$name")  |         finalPath=$($binDir/nix-store --print-fixed-path "$hashType" "$hash" "$name")  | ||||||
|         if ! @bindir@/nix-store --check-validity "$finalPath" 2> /dev/null; then |         if ! $binDir/nix-store --check-validity "$finalPath" 2> /dev/null; then | ||||||
|             echo "cached contents of \`$url' disappeared, redownloading..." >&2 |             echo "cached contents of \`$url' disappeared, redownloading..." >&2 | ||||||
|             finalPath= |             finalPath= | ||||||
|             cacheFlags="--remote-time" |             cacheFlags="--remote-time" | ||||||
|  | @ -133,7 +136,7 @@ if test -z "$finalPath"; then | ||||||
|     if test -z "$finalPath"; then |     if test -z "$finalPath"; then | ||||||
| 
 | 
 | ||||||
|         # Compute the hash. |         # Compute the hash. | ||||||
|         hash=$(@bindir@/nix-hash --type "$hashType" $hashFormat --flat $tmpFile) |         hash=$($binDir/nix-hash --type "$hashType" $hashFormat --flat $tmpFile) | ||||||
|         if ! test -n "$QUIET"; then echo "hash is $hash" >&2; fi |         if ! test -n "$QUIET"; then echo "hash is $hash" >&2; fi | ||||||
| 
 | 
 | ||||||
|         if test -n "$NIX_DOWNLOAD_CACHE"; then |         if test -n "$NIX_DOWNLOAD_CACHE"; then | ||||||
|  | @ -142,7 +145,7 @@ if test -z "$finalPath"; then | ||||||
|         fi |         fi | ||||||
| 
 | 
 | ||||||
|         # Add the downloaded file to the Nix store. |         # Add the downloaded file to the Nix store. | ||||||
|         finalPath=$(@bindir@/nix-store --add-fixed "$hashType" $tmpFile) |         finalPath=$($binDir/nix-store --add-fixed "$hashType" $tmpFile) | ||||||
| 
 | 
 | ||||||
|         if test -n "$expHash" -a "$expHash" != "$hash"; then |         if test -n "$expHash" -a "$expHash" != "$hash"; then | ||||||
|             echo "hash mismatch for URL \`$url'" >&2 |             echo "hash mismatch for URL \`$url'" >&2 | ||||||
|  |  | ||||||
							
								
								
									
										20
									
								
								scripts/nix-pull.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										20
									
								
								scripts/nix-pull.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							|  | @ -1,17 +1,17 @@ | ||||||
| #! @perl@ -w -I@libexecdir@/nix @perlFlags@ | #! @perl@ -w @perlFlags@ | ||||||
| 
 | 
 | ||||||
| use strict; | use strict; | ||||||
| use File::Temp qw(tempdir); | use File::Temp qw(tempdir); | ||||||
| use NixManifest; | use Nix::Config; | ||||||
|  | use Nix::Manifest; | ||||||
| 
 | 
 | ||||||
| my $tmpDir = tempdir("nix-pull.XXXXXX", CLEANUP => 1, TMPDIR => 1) | my $tmpDir = tempdir("nix-pull.XXXXXX", CLEANUP => 1, TMPDIR => 1) | ||||||
|     or die "cannot create a temporary directory"; |     or die "cannot create a temporary directory"; | ||||||
| 
 | 
 | ||||||
| my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; |  | ||||||
| my $libexecDir = ($ENV{"NIX_LIBEXEC_DIR"} or "@libexecdir@"); | my $libexecDir = ($ENV{"NIX_LIBEXEC_DIR"} or "@libexecdir@"); | ||||||
| my $storeDir = ($ENV{"NIX_STORE_DIR"} or "@storedir@"); | my $storeDir = ($ENV{"NIX_STORE_DIR"} or "@storedir@"); | ||||||
| my $stateDir = ($ENV{"NIX_STATE_DIR"} or "@localstatedir@/nix"); | my $stateDir = ($ENV{"NIX_STATE_DIR"} or "@localstatedir@/nix"); | ||||||
| my $manifestDir = ($ENV{"NIX_MANIFESTS_DIR"} or "$stateDir/manifests"); | my $manifestDir = $Nix::Config::manifestDir; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # Prevent access problems in shared-stored installations. | # Prevent access problems in shared-stored installations. | ||||||
|  | @ -42,7 +42,7 @@ sub downloadFile { | ||||||
|     my $url = shift; |     my $url = shift; | ||||||
|     $ENV{"PRINT_PATH"} = 1; |     $ENV{"PRINT_PATH"} = 1; | ||||||
|     $ENV{"QUIET"} = 1; |     $ENV{"QUIET"} = 1; | ||||||
|     my ($dummy, $path) = `$binDir/nix-prefetch-url '$url'`; |     my ($dummy, $path) = `$Nix::Config::binDir/nix-prefetch-url '$url'`; | ||||||
|     die "cannot fetch `$url'" if $? != 0; |     die "cannot fetch `$url'" if $? != 0; | ||||||
|     die "nix-prefetch-url did not return a path" unless defined $path; |     die "nix-prefetch-url did not return a path" unless defined $path; | ||||||
|     chomp $path; |     chomp $path; | ||||||
|  | @ -57,23 +57,23 @@ sub processURL { | ||||||
|     my $manifest; |     my $manifest; | ||||||
| 
 | 
 | ||||||
|     # First see if a bzipped manifest is available. |     # First see if a bzipped manifest is available. | ||||||
|     if (system("@curl@ --fail --silent --head '$url'.bz2 > /dev/null") == 0) { |     if (system("$Nix::Config::curl --fail --silent --head '$url'.bz2 > /dev/null") == 0) { | ||||||
|         print "fetching list of Nix archives at `$url.bz2'...\n"; |         print "fetching list of Nix archives at `$url.bz2'...\n"; | ||||||
|         my $bzipped = downloadFile "$url.bz2"; |         my $bzipped = downloadFile "$url.bz2"; | ||||||
| 
 | 
 | ||||||
|         $manifest = "$tmpDir/MANIFEST"; |         $manifest = "$tmpDir/MANIFEST"; | ||||||
| 
 | 
 | ||||||
|         system("@bunzip2@ < $bzipped > $manifest") == 0 |         system("$Nix::Config::bzip2 -d < $bzipped > $manifest") == 0 | ||||||
|             or die "cannot decompress manifest"; |             or die "cannot decompress manifest"; | ||||||
| 
 | 
 | ||||||
|         $manifest = (`$binDir/nix-store --add $manifest` |         $manifest = (`$Nix::Config::binDir/nix-store --add $manifest` | ||||||
|                      or die "cannot copy $manifest to the store"); |                      or die "cannot copy $manifest to the store"); | ||||||
|         chomp $manifest; |         chomp $manifest; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     # Otherwise, just get the uncompressed manifest. |     # Otherwise, just get the uncompressed manifest. | ||||||
|     else { |     else { | ||||||
|         print "obtaining list of Nix archives at `$url'...\n"; |         print "fetching list of Nix archives at `$url'...\n"; | ||||||
|         $manifest = downloadFile $url; |         $manifest = downloadFile $url; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -96,7 +96,7 @@ sub processURL { | ||||||
|         $baseName = $1; |         $baseName = $1; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     my $hash = `$binDir/nix-hash --flat '$manifest'` |     my $hash = `$Nix::Config::binDir/nix-hash --flat '$manifest'` | ||||||
|         or die "cannot hash `$manifest'"; |         or die "cannot hash `$manifest'"; | ||||||
|     chomp $hash; |     chomp $hash; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										7
									
								
								scripts/nix-push.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										7
									
								
								scripts/nix-push.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							|  | @ -1,9 +1,10 @@ | ||||||
| #! @perl@ -w -I@libexecdir@/nix @perlFlags@ | #! @perl@ -w @perlFlags@ | ||||||
| 
 | 
 | ||||||
| use strict; | use strict; | ||||||
| use File::Temp qw(tempdir); | use File::Temp qw(tempdir); | ||||||
| use File::stat; | use File::stat; | ||||||
| use NixManifest; | use Nix::Config; | ||||||
|  | use Nix::Manifest; | ||||||
| 
 | 
 | ||||||
| my $hashAlgo = "sha256"; | my $hashAlgo = "sha256"; | ||||||
| 
 | 
 | ||||||
|  | @ -13,7 +14,7 @@ my $tmpDir = tempdir("nix-push.XXXXXX", CLEANUP => 1, TMPDIR => 1) | ||||||
| my $nixExpr = "$tmpDir/create-nars.nix"; | my $nixExpr = "$tmpDir/create-nars.nix"; | ||||||
| my $manifest = "$tmpDir/MANIFEST"; | my $manifest = "$tmpDir/MANIFEST"; | ||||||
| 
 | 
 | ||||||
| my $curl = "@curl@ --fail --silent"; | my $curl = "$Nix::Config::curl --fail --silent"; | ||||||
| my $extraCurlFlags = ${ENV{'CURL_FLAGS'}}; | my $extraCurlFlags = ${ENV{'CURL_FLAGS'}}; | ||||||
| $curl = "$curl $extraCurlFlags" if defined $extraCurlFlags; | $curl = "$curl $extraCurlFlags" if defined $extraCurlFlags; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										0
									
								
								scripts/nix-reduce-build.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								scripts/nix-reduce-build.in
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							|  | @ -1,52 +0,0 @@ | ||||||
| #! /usr/bin/perl -w -I. |  | ||||||
| 
 |  | ||||||
| use strict; |  | ||||||
| use readmanifest; |  | ||||||
| 
 |  | ||||||
| die unless scalar @ARGV == 2; |  | ||||||
| 
 |  | ||||||
| my $cache = $ARGV[0]; |  | ||||||
| my $manifest = $ARGV[1]; |  | ||||||
| my %narFiles; |  | ||||||
| my %patches; |  | ||||||
| 
 |  | ||||||
| readManifest $manifest, \%narFiles, \%patches; |  | ||||||
| 
 |  | ||||||
| foreach my $storePath (keys %narFiles) { |  | ||||||
|     my $narFileList = $narFiles{$storePath}; |  | ||||||
| 
 |  | ||||||
|     foreach my $narFile (@{$narFileList}) { |  | ||||||
|         if (!defined $narFile->{size} or |  | ||||||
|             !defined $narFile->{narHash}) |  | ||||||
|         { |  | ||||||
|             $narFile->{url} =~ /\/([^\/]+)$/; |  | ||||||
|             die unless defined $1; |  | ||||||
|             my $fn = "$cache/$1"; |  | ||||||
|              |  | ||||||
|             my @info = stat $fn or die; |  | ||||||
|             $narFile->{size} = $info[7]; |  | ||||||
| 
 |  | ||||||
|             my $narHash; |  | ||||||
|             my $hashFile = "$fn.NARHASH"; |  | ||||||
|             if (-e $hashFile) { |  | ||||||
|                 open HASH, "<$hashFile" or die; |  | ||||||
|                 $narHash = <HASH>; |  | ||||||
|                 close HASH; |  | ||||||
|             } else { |  | ||||||
|                 print "$fn\n"; |  | ||||||
|                 $narHash = `bunzip2 < '$fn' | nix-hash --flat /dev/stdin` or die; |  | ||||||
|                 open HASH, ">$hashFile" or die; |  | ||||||
|                 print HASH $narHash; |  | ||||||
|                 close HASH; |  | ||||||
|             } |  | ||||||
|             chomp $narHash; |  | ||||||
|             $narFile->{narHash} = $narHash; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| if (! -e "$manifest.backup") { |  | ||||||
|     system "mv --reply=no '$manifest' '$manifest.backup'"; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| writeManifest $manifest, \%narFiles, \%patches; |  | ||||||
|  | @ -172,7 +172,7 @@ EvalState::EvalState() | ||||||
| #if HAVE_SYSCONF && defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES) | #if HAVE_SYSCONF && defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES) | ||||||
|             long pageSize = sysconf(_SC_PAGESIZE); |             long pageSize = sysconf(_SC_PAGESIZE); | ||||||
|             long pages = sysconf(_SC_PHYS_PAGES); |             long pages = sysconf(_SC_PHYS_PAGES); | ||||||
|             if (pageSize != -1 && size != -1) |             if (pageSize != -1) | ||||||
|                 size = (pageSize * pages) / 4; // 25% of RAM
 |                 size = (pageSize * pages) / 4; // 25% of RAM
 | ||||||
|             if (size > maxSize) size = maxSize; |             if (size > maxSize) size = maxSize; | ||||||
| #endif | #endif | ||||||
|  | @ -1109,7 +1109,10 @@ bool EvalState::isDerivation(Value & v) | ||||||
| { | { | ||||||
|     if (v.type != tAttrs) return false; |     if (v.type != tAttrs) return false; | ||||||
|     Bindings::iterator i = v.attrs->find(sType); |     Bindings::iterator i = v.attrs->find(sType); | ||||||
|     return i != v.attrs->end() && forceStringNoCtx(*i->value) == "derivation"; |     if (i == v.attrs->end()) return false; | ||||||
|  |     forceValue(*i->value); | ||||||
|  |     if (i->value->type != tString) return false; | ||||||
|  |     return forceStringNoCtx(*i->value) == "derivation"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -239,7 +239,8 @@ Hash hashDerivationModulo(StoreAPI & store, Derivation drv) | ||||||
|     foreach (DerivationInputs::const_iterator, i, drv.inputDrvs) { |     foreach (DerivationInputs::const_iterator, i, drv.inputDrvs) { | ||||||
|         Hash h = drvHashes[i->first]; |         Hash h = drvHashes[i->first]; | ||||||
|         if (h.type == htUnknown) { |         if (h.type == htUnknown) { | ||||||
|             Derivation drv2 = derivationFromPath(store, i->first); |             assert(store.isValidPath(i->first)); | ||||||
|  |             Derivation drv2 = parseDerivation(readFile(i->first)); | ||||||
|             h = hashDerivationModulo(store, drv2); |             h = hashDerivationModulo(store, drv2); | ||||||
|             drvHashes[i->first] = h; |             drvHashes[i->first] = h; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -510,7 +510,7 @@ void LocalStore::checkDerivationOutputs(const Path & drvPath, const Derivation & | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| unsigned long long LocalStore::addValidPath(const ValidPathInfo & info) | unsigned long long LocalStore::addValidPath(const ValidPathInfo & info, bool checkOutputs) | ||||||
| { | { | ||||||
|     SQLiteStmtUse use(stmtRegisterValidPath); |     SQLiteStmtUse use(stmtRegisterValidPath); | ||||||
|     stmtRegisterValidPath.bind(info.path); |     stmtRegisterValidPath.bind(info.path); | ||||||
|  | @ -540,7 +540,7 @@ unsigned long long LocalStore::addValidPath(const ValidPathInfo & info) | ||||||
|            derivations).  Note that if this throws an error, then the |            derivations).  Note that if this throws an error, then the | ||||||
|            DB transaction is rolled back, so the path validity |            DB transaction is rolled back, so the path validity | ||||||
|            registration above is undone. */ |            registration above is undone. */ | ||||||
|         checkDerivationOutputs(info.path, drv); |         if (checkOutputs) checkDerivationOutputs(info.path, drv); | ||||||
|          |          | ||||||
|         foreach (DerivationOutputs::iterator, i, drv.outputs) { |         foreach (DerivationOutputs::iterator, i, drv.outputs) { | ||||||
|             SQLiteStmtUse use(stmtAddDerivationOutput); |             SQLiteStmtUse use(stmtAddDerivationOutput); | ||||||
|  | @ -1521,7 +1521,7 @@ void LocalStore::upgradeStore6() | ||||||
|     SQLiteTxn txn(db); |     SQLiteTxn txn(db); | ||||||
|      |      | ||||||
|     foreach (PathSet::iterator, i, validPaths) { |     foreach (PathSet::iterator, i, validPaths) { | ||||||
|         addValidPath(queryPathInfoOld(*i)); |         addValidPath(queryPathInfoOld(*i), false); | ||||||
|         std::cerr << "."; |         std::cerr << "."; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -226,7 +226,7 @@ private: | ||||||
| 
 | 
 | ||||||
|     unsigned long long queryValidPathId(const Path & path); |     unsigned long long queryValidPathId(const Path & path); | ||||||
| 
 | 
 | ||||||
|     unsigned long long addValidPath(const ValidPathInfo & info); |     unsigned long long addValidPath(const ValidPathInfo & info, bool checkOutputs = true); | ||||||
|          |          | ||||||
|     void addReference(unsigned long long referrer, unsigned long long reference); |     void addReference(unsigned long long referrer, unsigned long long reference); | ||||||
|      |      | ||||||
|  |  | ||||||
|  | @ -6,13 +6,13 @@ | ||||||
| 	 -e "s^@sysconfdir\@^$(sysconfdir)^g" \
 | 	 -e "s^@sysconfdir\@^$(sysconfdir)^g" \
 | ||||||
| 	 -e "s^@localstatedir\@^$(localstatedir)^g" \
 | 	 -e "s^@localstatedir\@^$(localstatedir)^g" \
 | ||||||
| 	 -e "s^@datadir\@^$(datadir)^g" \
 | 	 -e "s^@datadir\@^$(datadir)^g" \
 | ||||||
|  | 	 -e "s^@libdir\@^$(libdir)^g" \
 | ||||||
| 	 -e "s^@libexecdir\@^$(libexecdir)^g" \
 | 	 -e "s^@libexecdir\@^$(libexecdir)^g" \
 | ||||||
| 	 -e "s^@storedir\@^$(storedir)^g" \
 | 	 -e "s^@storedir\@^$(storedir)^g" \
 | ||||||
| 	 -e "s^@system\@^$(system)^g" \
 | 	 -e "s^@system\@^$(system)^g" \
 | ||||||
| 	 -e "s^@shell\@^$(bash)^g" \
 | 	 -e "s^@shell\@^$(bash)^g" \
 | ||||||
| 	 -e "s^@curl\@^$(curl)^g" \
 | 	 -e "s^@curl\@^$(curl)^g" \
 | ||||||
| 	 -e "s^@bzip2\@^$(bzip2_bin)/bzip2^g" \
 | 	 -e "s^@bzip2\@^$(bzip2_bin)/bzip2^g" \
 | ||||||
| 	 -e "s^@bunzip2\@^$(bzip2_bin)/bunzip2^g" \
 |  | ||||||
| 	 -e "s^@bzip2_bin_test\@^$(bzip2_bin_test)^g" \
 | 	 -e "s^@bzip2_bin_test\@^$(bzip2_bin_test)^g" \
 | ||||||
| 	 -e "s^@perl\@^$(perl)^g" \
 | 	 -e "s^@perl\@^$(perl)^g" \
 | ||||||
| 	 -e "s^@perlFlags\@^$(perlFlags)^g" \
 | 	 -e "s^@perlFlags\@^$(perlFlags)^g" \
 | ||||||
|  |  | ||||||
							
								
								
									
										12
									
								
								tests/add.sh
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								tests/add.sh
									
										
									
									
									
								
							|  | @ -1,9 +1,9 @@ | ||||||
| source common.sh | source common.sh | ||||||
| 
 | 
 | ||||||
| path1=$($nixstore --add ./dummy) | path1=$(nix-store --add ./dummy) | ||||||
| echo $path1 | echo $path1 | ||||||
| 
 | 
 | ||||||
| path2=$($nixstore --add-fixed sha256 --recursive ./dummy) | path2=$(nix-store --add-fixed sha256 --recursive ./dummy) | ||||||
| echo $path2 | echo $path2 | ||||||
| 
 | 
 | ||||||
| if test "$path1" != "$path2"; then | if test "$path1" != "$path2"; then | ||||||
|  | @ -11,18 +11,18 @@ if test "$path1" != "$path2"; then | ||||||
|     exit 1 |     exit 1 | ||||||
| fi     | fi     | ||||||
| 
 | 
 | ||||||
| path3=$($nixstore --add-fixed sha256 ./dummy) | path3=$(nix-store --add-fixed sha256 ./dummy) | ||||||
| echo $path3 | echo $path3 | ||||||
| test "$path1" != "$path3" || exit 1 | test "$path1" != "$path3" || exit 1 | ||||||
| 
 | 
 | ||||||
| path4=$($nixstore --add-fixed sha1 --recursive ./dummy) | path4=$(nix-store --add-fixed sha1 --recursive ./dummy) | ||||||
| echo $path4 | echo $path4 | ||||||
| test "$path1" != "$path4" || exit 1 | test "$path1" != "$path4" || exit 1 | ||||||
| 
 | 
 | ||||||
| hash1=$($nixstore -q --hash $path1) | hash1=$(nix-store -q --hash $path1) | ||||||
| echo $hash1 | echo $hash1 | ||||||
| 
 | 
 | ||||||
| hash2=$($nixhash --type sha256 --base32 ./dummy) | hash2=$(nix-hash --type sha256 --base32 ./dummy) | ||||||
| echo $hash2 | echo $hash2 | ||||||
| 
 | 
 | ||||||
| test "$hash1" = "sha256:$hash2" | test "$hash1" = "sha256:$hash2" | ||||||
|  |  | ||||||
|  | @ -7,52 +7,52 @@ mkdir -p $TEST_ROOT/cache2 $TEST_ROOT/patches | ||||||
| RESULT=$TEST_ROOT/result | RESULT=$TEST_ROOT/result | ||||||
| 
 | 
 | ||||||
| # Build version 1 and 2 of the "foo" package. | # Build version 1 and 2 of the "foo" package. | ||||||
| $NIX_BIN_DIR/nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest1 \ | nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest1 \ | ||||||
|     $($nixbuild -o $RESULT binary-patching.nix --arg version 1) |     $(nix-build -o $RESULT binary-patching.nix --arg version 1) | ||||||
| 
 | 
 | ||||||
| out2=$($nixbuild -o $RESULT binary-patching.nix --arg version 2) | out2=$(nix-build -o $RESULT binary-patching.nix --arg version 2) | ||||||
| $NIX_BIN_DIR/nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest2 $out2 | nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest2 $out2 | ||||||
|      |      | ||||||
| out3=$($nixbuild -o $RESULT binary-patching.nix --arg version 3) | out3=$(nix-build -o $RESULT binary-patching.nix --arg version 3) | ||||||
| $NIX_BIN_DIR/nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest3 $out3 | nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest3 $out3 | ||||||
| 
 | 
 | ||||||
| rm $RESULT | rm $RESULT | ||||||
| 
 | 
 | ||||||
| # Generate binary patches. | # Generate binary patches. | ||||||
| $NIX_BIN_DIR/nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \ | nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \ | ||||||
|     file://$TEST_ROOT/patches $TEST_ROOT/manifest1 $TEST_ROOT/manifest2 |     file://$TEST_ROOT/patches $TEST_ROOT/manifest1 $TEST_ROOT/manifest2 | ||||||
| 
 | 
 | ||||||
| $NIX_BIN_DIR/nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \ | nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \ | ||||||
|     file://$TEST_ROOT/patches $TEST_ROOT/manifest2 $TEST_ROOT/manifest3 |     file://$TEST_ROOT/patches $TEST_ROOT/manifest2 $TEST_ROOT/manifest3 | ||||||
| 
 | 
 | ||||||
| grep -q "patch {" $TEST_ROOT/manifest3 | grep -q "patch {" $TEST_ROOT/manifest3 | ||||||
| 
 | 
 | ||||||
| # Get rid of versions 2 and 3. | # Get rid of versions 2 and 3. | ||||||
| $nixstore --delete $out2 $out3 | nix-store --delete $out2 $out3 | ||||||
| 
 | 
 | ||||||
| # Pull the manifest containing the patches. | # Pull the manifest containing the patches. | ||||||
| clearManifests | clearManifests | ||||||
| $NIX_BIN_DIR/nix-pull file://$TEST_ROOT/manifest3 | nix-pull file://$TEST_ROOT/manifest3 | ||||||
| 
 | 
 | ||||||
| # Make sure that the download size prediction uses the patches rather | # Make sure that the download size prediction uses the patches rather | ||||||
| # than the full download. | # than the full download. | ||||||
| $nixbuild -o $RESULT binary-patching.nix --arg version 3 --dry-run 2>&1 | grep -q "0.01 MiB" | nix-build -o $RESULT binary-patching.nix --arg version 3 --dry-run 2>&1 | grep -q "0.01 MiB" | ||||||
| 
 | 
 | ||||||
| # Now rebuild it.  This should use the two patches generated above. | # Now rebuild it.  This should use the two patches generated above. | ||||||
| rm -f $TEST_ROOT/var/log/nix/downloads | rm -f $TEST_ROOT/var/log/nix/downloads | ||||||
| $nixbuild -o $RESULT binary-patching.nix --arg version 3 | nix-build -o $RESULT binary-patching.nix --arg version 3 | ||||||
| rm $RESULT | rm $RESULT | ||||||
| [ "$(grep ' patch ' $TEST_ROOT/var/log/nix/downloads | wc -l)" -eq 2 ] | [ "$(grep ' patch ' $TEST_ROOT/var/log/nix/downloads | wc -l)" -eq 2 ] | ||||||
| 
 | 
 | ||||||
| # Add a patch from version 1 directly to version 3. | # Add a patch from version 1 directly to version 3. | ||||||
| $NIX_BIN_DIR/nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \ | nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \ | ||||||
|     file://$TEST_ROOT/patches $TEST_ROOT/manifest1 $TEST_ROOT/manifest3 |     file://$TEST_ROOT/patches $TEST_ROOT/manifest1 $TEST_ROOT/manifest3 | ||||||
| 
 | 
 | ||||||
| # Rebuild version 3.  This should use the direct patch rather than the | # Rebuild version 3.  This should use the direct patch rather than the | ||||||
| # sequence of two patches. | # sequence of two patches. | ||||||
| $nixstore --delete $out2 $out3 | nix-store --delete $out2 $out3 | ||||||
| clearManifests | clearManifests | ||||||
| rm $TEST_ROOT/var/log/nix/downloads | rm $TEST_ROOT/var/log/nix/downloads | ||||||
| $NIX_BIN_DIR/nix-pull file://$TEST_ROOT/manifest3 | nix-pull file://$TEST_ROOT/manifest3 | ||||||
| $nixbuild -o $RESULT binary-patching.nix --arg version 3 | nix-build -o $RESULT binary-patching.nix --arg version 3 | ||||||
| [ "$(grep ' patch ' $TEST_ROOT/var/log/nix/downloads | wc -l)" -eq 1 ] | [ "$(grep ' patch ' $TEST_ROOT/var/log/nix/downloads | wc -l)" -eq 1 ] | ||||||
|  |  | ||||||
|  | @ -2,7 +2,7 @@ source common.sh | ||||||
| 
 | 
 | ||||||
| export NIX_BUILD_HOOK="build-hook.hook.sh" | export NIX_BUILD_HOOK="build-hook.hook.sh" | ||||||
| 
 | 
 | ||||||
| outPath=$($nixbuild build-hook.nix) | outPath=$(nix-build build-hook.nix) | ||||||
| 
 | 
 | ||||||
| echo "output path is $outPath" | echo "output path is $outPath" | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -4,33 +4,33 @@ set -x | ||||||
| 
 | 
 | ||||||
| RESULT=$TEST_ROOT/result | RESULT=$TEST_ROOT/result | ||||||
| 
 | 
 | ||||||
| dep=$($nixbuild -o $RESULT check-refs.nix -A dep) | dep=$(nix-build -o $RESULT check-refs.nix -A dep) | ||||||
| 
 | 
 | ||||||
| # test1 references dep, not itself. | # test1 references dep, not itself. | ||||||
| test1=$($nixbuild -o $RESULT check-refs.nix -A test1) | test1=$(nix-build -o $RESULT check-refs.nix -A test1) | ||||||
| ! $nixstore -q --references $test1 | grep -q $test1 | ! nix-store -q --references $test1 | grep -q $test1 | ||||||
| $nixstore -q --references $test1 | grep -q $dep | nix-store -q --references $test1 | grep -q $dep | ||||||
| 
 | 
 | ||||||
| # test2 references src, not itself nor dep. | # test2 references src, not itself nor dep. | ||||||
| test2=$($nixbuild -o $RESULT check-refs.nix -A test2) | test2=$(nix-build -o $RESULT check-refs.nix -A test2) | ||||||
| ! $nixstore -q --references $test2 | grep -q $test2 | ! nix-store -q --references $test2 | grep -q $test2 | ||||||
| ! $nixstore -q --references $test2 | grep -q $dep | ! nix-store -q --references $test2 | grep -q $dep | ||||||
| $nixstore -q --references $test2 | grep -q aux-ref | nix-store -q --references $test2 | grep -q aux-ref | ||||||
| 
 | 
 | ||||||
| # test3 should fail (unallowed ref). | # test3 should fail (unallowed ref). | ||||||
| ! $nixbuild -o $RESULT check-refs.nix -A test3 | ! nix-build -o $RESULT check-refs.nix -A test3 | ||||||
| 
 | 
 | ||||||
| # test4 should succeed. | # test4 should succeed. | ||||||
| $nixbuild -o $RESULT check-refs.nix -A test4 | nix-build -o $RESULT check-refs.nix -A test4 | ||||||
| 
 | 
 | ||||||
| # test5 should succeed. | # test5 should succeed. | ||||||
| $nixbuild -o $RESULT check-refs.nix -A test5 | nix-build -o $RESULT check-refs.nix -A test5 | ||||||
| 
 | 
 | ||||||
| # test6 should fail (unallowed self-ref). | # test6 should fail (unallowed self-ref). | ||||||
| ! $nixbuild -o $RESULT check-refs.nix -A test6 | ! nix-build -o $RESULT check-refs.nix -A test6 | ||||||
| 
 | 
 | ||||||
| # test7 should succeed (allowed self-ref). | # test7 should succeed (allowed self-ref). | ||||||
| $nixbuild -o $RESULT check-refs.nix -A test7 | nix-build -o $RESULT check-refs.nix -A test7 | ||||||
| 
 | 
 | ||||||
| # test8 should fail (toFile depending on derivation output). | # test8 should fail (toFile depending on derivation output). | ||||||
| ! $nixbuild -o $RESULT check-refs.nix -A test8 | ! nix-build -o $RESULT check-refs.nix -A test8 | ||||||
|  |  | ||||||
|  | @ -1,5 +1,7 @@ | ||||||
| set -e | set -e | ||||||
| 
 | 
 | ||||||
|  | export TOP=$(pwd)/.. | ||||||
|  | 
 | ||||||
| export TEST_ROOT=$(pwd)/test-tmp | export TEST_ROOT=$(pwd)/test-tmp | ||||||
| export NIX_STORE_DIR | export NIX_STORE_DIR | ||||||
| if ! NIX_STORE_DIR=$(readlink -f $TEST_ROOT/store 2> /dev/null); then | if ! NIX_STORE_DIR=$(readlink -f $TEST_ROOT/store 2> /dev/null); then | ||||||
|  | @ -15,9 +17,12 @@ export NIX_DB_DIR=$TEST_ROOT/db | ||||||
| export NIX_CONF_DIR=$TEST_ROOT/etc | export NIX_CONF_DIR=$TEST_ROOT/etc | ||||||
| export NIX_BIN_DIR=$TEST_ROOT/bin | export NIX_BIN_DIR=$TEST_ROOT/bin | ||||||
| export NIX_LIBEXEC_DIR=$TEST_ROOT/bin | export NIX_LIBEXEC_DIR=$TEST_ROOT/bin | ||||||
|  | export NIX_MANIFESTS_DIR=$TEST_ROOT/var/nix/manifests | ||||||
| export NIX_ROOT_FINDER= | export NIX_ROOT_FINDER= | ||||||
| export SHARED=$TEST_ROOT/shared | export SHARED=$TEST_ROOT/shared | ||||||
| 
 | 
 | ||||||
|  | export PATH=$NIX_BIN_DIR:$TOP/scripts:$PATH | ||||||
|  | 
 | ||||||
| export NIX_REMOTE= | export NIX_REMOTE= | ||||||
| 
 | 
 | ||||||
| export REAL_BIN_DIR=@bindir@ | export REAL_BIN_DIR=@bindir@ | ||||||
|  | @ -27,10 +32,10 @@ export REAL_DATA_DIR=@datadir@ | ||||||
| export REAL_STORE_DIR=@storedir@ | export REAL_STORE_DIR=@storedir@ | ||||||
| export NIX_BUILD_HOOK= | export NIX_BUILD_HOOK= | ||||||
| export PERL=perl | export PERL=perl | ||||||
| export TOP=$(pwd)/.. | export PERL5LIB=$TOP/perl/lib:$PERL5LIB | ||||||
| export bzip2_bin_test="@bzip2_bin_test@" | export NIX_BZIP2="@bzip2_bin_test@/bzip2" | ||||||
| if test "${bzip2_bin_test:0:1}" != "/"; then | if test "${NIX_BZIP2:0:1}" != "/"; then | ||||||
|     bzip2_bin_test=`pwd`/${bzip2_bin_test} |     NIX_BZIP2=`pwd`/${NIX_BZIP2} | ||||||
| fi | fi | ||||||
| export dot=@dot@ | export dot=@dot@ | ||||||
| export xmllint="@xmllint@" | export xmllint="@xmllint@" | ||||||
|  | @ -42,13 +47,6 @@ export SHELL="@shell@" | ||||||
| export version=@version@ | export version=@version@ | ||||||
| export system=@system@ | export system=@system@ | ||||||
| 
 | 
 | ||||||
| export nixinstantiate=$TOP/src/nix-instantiate/nix-instantiate |  | ||||||
| export nixstore=$TOP/src/nix-store/nix-store |  | ||||||
| export nixenv=$TOP/src/nix-env/nix-env |  | ||||||
| export nixhash=$TOP/src/nix-hash/nix-hash |  | ||||||
| export nixworker=$TOP/src/nix-worker/nix-worker |  | ||||||
| export nixbuild=$NIX_BIN_DIR/nix-build |  | ||||||
| 
 |  | ||||||
| readLink() { | readLink() { | ||||||
|     ls -l "$1" | sed 's/.*->\ //' |     ls -l "$1" | sed 's/.*->\ //' | ||||||
| } | } | ||||||
|  | @ -65,7 +63,7 @@ clearStore() { | ||||||
|     mkdir "$NIX_STORE_DIR" |     mkdir "$NIX_STORE_DIR" | ||||||
|     rm -rf "$NIX_DB_DIR" |     rm -rf "$NIX_DB_DIR" | ||||||
|     mkdir "$NIX_DB_DIR" |     mkdir "$NIX_DB_DIR" | ||||||
|     $nixstore --init |     nix-store --init | ||||||
|     clearProfiles |     clearProfiles | ||||||
|     rm -f "$NIX_STATE_DIR"/gcroots/auto/* |     rm -f "$NIX_STATE_DIR"/gcroots/auto/* | ||||||
|     rm -f "$NIX_STATE_DIR"/gcroots/ref |     rm -f "$NIX_STATE_DIR"/gcroots/ref | ||||||
|  | @ -76,7 +74,14 @@ clearManifests() { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| startDaemon() { | startDaemon() { | ||||||
|     $nixworker --daemon & |     # Start the daemon, wait for the socket to appear.  !!! | ||||||
|  |     # ‘nix-worker’ should have an option to fork into the background. | ||||||
|  |     rm -f $NIX_STATE_DIR/daemon-socket/socket | ||||||
|  |     nix-worker --daemon & | ||||||
|  |     for ((i = 0; i < 30; i++)); do | ||||||
|  |         if [ -e $NIX_STATE_DIR/daemon-socket/socket ]; then break; fi | ||||||
|  |         sleep 1 | ||||||
|  |     done | ||||||
|     pidDaemon=$! |     pidDaemon=$! | ||||||
|     trap "kill -9 $pidDaemon" EXIT |     trap "kill -9 $pidDaemon" EXIT | ||||||
|     export NIX_REMOTE=daemon |     export NIX_REMOTE=daemon | ||||||
|  |  | ||||||
|  | @ -2,36 +2,36 @@ source common.sh | ||||||
| 
 | 
 | ||||||
| clearStore | clearStore | ||||||
| 
 | 
 | ||||||
| drvPath=$($nixinstantiate dependencies.nix) | drvPath=$(nix-instantiate dependencies.nix) | ||||||
| 
 | 
 | ||||||
| echo "derivation is $drvPath" | echo "derivation is $drvPath" | ||||||
| 
 | 
 | ||||||
| $nixstore -q --tree "$drvPath" | grep '   +---.*builder1.sh' | nix-store -q --tree "$drvPath" | grep '   +---.*builder1.sh' | ||||||
| 
 | 
 | ||||||
| # Test Graphviz graph generation. | # Test Graphviz graph generation. | ||||||
| $nixstore -q --graph "$drvPath" > $TEST_ROOT/graph | nix-store -q --graph "$drvPath" > $TEST_ROOT/graph | ||||||
| if test -n "$dot"; then | if test -n "$dot"; then | ||||||
|     # Does it parse? |     # Does it parse? | ||||||
|     $dot < $TEST_ROOT/graph |     $dot < $TEST_ROOT/graph | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| outPath=$($nixstore -rvv "$drvPath") || fail "build failed" | outPath=$(nix-store -rvv "$drvPath") || fail "build failed" | ||||||
| 
 | 
 | ||||||
| # Test Graphviz graph generation. | # Test Graphviz graph generation. | ||||||
| $nixstore -q --graph "$outPath" > $TEST_ROOT/graph | nix-store -q --graph "$outPath" > $TEST_ROOT/graph | ||||||
| if test -n "$dot"; then | if test -n "$dot"; then | ||||||
|     # Does it parse? |     # Does it parse? | ||||||
|     $dot < $TEST_ROOT/graph |     $dot < $TEST_ROOT/graph | ||||||
| fi     | fi     | ||||||
| 
 | 
 | ||||||
| $nixstore -q --tree "$outPath" | grep '+---.*dependencies-input-2' | nix-store -q --tree "$outPath" | grep '+---.*dependencies-input-2' | ||||||
| 
 | 
 | ||||||
| echo "output path is $outPath" | echo "output path is $outPath" | ||||||
| 
 | 
 | ||||||
| text=$(cat "$outPath"/foobar) | text=$(cat "$outPath"/foobar) | ||||||
| if test "$text" != "FOOBAR"; then exit 1; fi | if test "$text" != "FOOBAR"; then exit 1; fi | ||||||
| 
 | 
 | ||||||
| deps=$($nixstore -quR "$drvPath") | deps=$(nix-store -quR "$drvPath") | ||||||
| 
 | 
 | ||||||
| echo "output closure contains $deps" | echo "output closure contains $deps" | ||||||
| 
 | 
 | ||||||
|  | @ -45,8 +45,8 @@ if echo "$deps" | grep -q "dependencies-input-1"; then exit 1; fi | ||||||
| input2OutPath=$(echo "$deps" | grep "dependencies-input-2") | input2OutPath=$(echo "$deps" | grep "dependencies-input-2") | ||||||
| 
 | 
 | ||||||
| # The referrers closure of input-2 should include outPath. | # The referrers closure of input-2 should include outPath. | ||||||
| $nixstore -q --referrers-closure "$input2OutPath" | grep "$outPath" | nix-store -q --referrers-closure "$input2OutPath" | grep "$outPath" | ||||||
| 
 | 
 | ||||||
| # Check that the derivers are set properly. | # Check that the derivers are set properly. | ||||||
| test $($nixstore -q --deriver "$outPath") = "$drvPath" | test $(nix-store -q --deriver "$outPath") = "$drvPath" | ||||||
| $nixstore -q --deriver "$input2OutPath" | grep -q -- "-input-2.drv"  | nix-store -q --deriver "$input2OutPath" | grep -q -- "-input-2.drv"  | ||||||
|  |  | ||||||
|  | @ -4,23 +4,23 @@ clearStore | ||||||
| clearProfiles | clearProfiles | ||||||
| 
 | 
 | ||||||
| checkRef() { | checkRef() { | ||||||
|     $nixstore -q --references ./result | grep -q "$1" || fail "missing reference $1" |     nix-store -q --references ./result | grep -q "$1" || fail "missing reference $1" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| # Test the export of the runtime dependency graph. | # Test the export of the runtime dependency graph. | ||||||
| 
 | 
 | ||||||
| outPath=$($nixbuild ./export-graph.nix -A runtimeGraph) | outPath=$(nix-build ./export-graph.nix -A runtimeGraph) | ||||||
| 
 | 
 | ||||||
| test $($nixstore -q --references ./result | wc -l) = 2 || fail "bad nr of references" | test $(nix-store -q --references ./result | wc -l) = 2 || fail "bad nr of references" | ||||||
| 
 | 
 | ||||||
| checkRef input-2 | checkRef input-2 | ||||||
| for i in $(cat $outPath); do checkRef $i; done | for i in $(cat $outPath); do checkRef $i; done | ||||||
| 
 | 
 | ||||||
| # Test the export of the build-time dependency graph. | # Test the export of the build-time dependency graph. | ||||||
| 
 | 
 | ||||||
| $nixstore --gc # should force rebuild of input-1 | nix-store --gc # should force rebuild of input-1 | ||||||
| 
 | 
 | ||||||
| outPath=$($nixbuild ./export-graph.nix -A buildGraph) | outPath=$(nix-build ./export-graph.nix -A buildGraph) | ||||||
| 
 | 
 | ||||||
| checkRef input-1 | checkRef input-1 | ||||||
| checkRef input-1.drv | checkRef input-1.drv | ||||||
|  |  | ||||||
|  | @ -2,16 +2,16 @@ source common.sh | ||||||
| 
 | 
 | ||||||
| clearStore | clearStore | ||||||
| 
 | 
 | ||||||
| outPath=$($nixbuild dependencies.nix) | outPath=$(nix-build dependencies.nix) | ||||||
| 
 | 
 | ||||||
| $nixstore --export $outPath > $TEST_ROOT/exp | nix-store --export $outPath > $TEST_ROOT/exp | ||||||
| 
 | 
 | ||||||
| $nixstore --export $($nixstore -qR $outPath) > $TEST_ROOT/exp_all | nix-store --export $(nix-store -qR $outPath) > $TEST_ROOT/exp_all | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| clearStore | clearStore | ||||||
| 
 | 
 | ||||||
| if $nixstore --import < $TEST_ROOT/exp; then | if nix-store --import < $TEST_ROOT/exp; then | ||||||
|     echo "importing a non-closure should fail" |     echo "importing a non-closure should fail" | ||||||
|     exit 1 |     exit 1 | ||||||
| fi | fi | ||||||
|  | @ -19,13 +19,13 @@ fi | ||||||
| 
 | 
 | ||||||
| clearStore | clearStore | ||||||
| 
 | 
 | ||||||
| $nixstore --import < $TEST_ROOT/exp_all | nix-store --import < $TEST_ROOT/exp_all | ||||||
| 
 | 
 | ||||||
| $nixstore --export $($nixstore -qR $outPath) > $TEST_ROOT/exp_all2 | nix-store --export $(nix-store -qR $outPath) > $TEST_ROOT/exp_all2 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| clearStore | clearStore | ||||||
| 
 | 
 | ||||||
| # Regression test: the derivers in exp_all2 are empty, which shouldn't | # Regression test: the derivers in exp_all2 are empty, which shouldn't | ||||||
| # cause a failure. | # cause a failure. | ||||||
| $nixstore --import < $TEST_ROOT/exp_all2 | nix-store --import < $TEST_ROOT/exp_all2 | ||||||
|  |  | ||||||
|  | @ -2,19 +2,19 @@ source common.sh | ||||||
| 
 | 
 | ||||||
| clearStore | clearStore | ||||||
| 
 | 
 | ||||||
| drvPath=$($nixinstantiate simple.nix) | drvPath=$(nix-instantiate simple.nix) | ||||||
| echo "derivation is $drvPath" | echo "derivation is $drvPath" | ||||||
| 
 | 
 | ||||||
| outPath=$($nixstore -q --fallback "$drvPath") | outPath=$(nix-store -q --fallback "$drvPath") | ||||||
| echo "output path is $outPath" | echo "output path is $outPath" | ||||||
| 
 | 
 | ||||||
| # Build with a substitute that fails.  This should fail. | # Build with a substitute that fails.  This should fail. | ||||||
| export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh | export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh | ||||||
| if $nixstore -r "$drvPath"; then echo unexpected fallback; exit 1; fi | if nix-store -r "$drvPath"; then echo unexpected fallback; exit 1; fi | ||||||
| 
 | 
 | ||||||
| # Build with a substitute that fails.  This should fall back to a source build. | # Build with a substitute that fails.  This should fall back to a source build. | ||||||
| export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh | export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh | ||||||
| $nixstore -r --fallback "$drvPath" | nix-store -r --fallback "$drvPath" | ||||||
| 
 | 
 | ||||||
| text=$(cat "$outPath"/hello) | text=$(cat "$outPath"/hello) | ||||||
| if test "$text" != "Hello World!"; then exit 1; fi | if test "$text" != "Hello World!"; then exit 1; fi | ||||||
|  |  | ||||||
|  | @ -10,7 +10,7 @@ touch $TEST_ROOT/filterin/bak | ||||||
| touch $TEST_ROOT/filterin/bla.c.bak | touch $TEST_ROOT/filterin/bla.c.bak | ||||||
| ln -s xyzzy $TEST_ROOT/filterin/link | ln -s xyzzy $TEST_ROOT/filterin/link | ||||||
| 
 | 
 | ||||||
| $NIX_BIN_DIR/nix-build ./filter-source.nix -o $TEST_ROOT/filterout | nix-build ./filter-source.nix -o $TEST_ROOT/filterout | ||||||
| 
 | 
 | ||||||
| set -x | set -x | ||||||
| test ! -e $TEST_ROOT/filterout/foo/bar | test ! -e $TEST_ROOT/filterout/foo/bar | ||||||
|  |  | ||||||
|  | @ -6,31 +6,31 @@ export IMPURE_VAR1=foo | ||||||
| export IMPURE_VAR2=bar | export IMPURE_VAR2=bar | ||||||
| 
 | 
 | ||||||
| echo 'testing good...' | echo 'testing good...' | ||||||
| $nixbuild fixed.nix -A good | nix-build fixed.nix -A good | ||||||
| 
 | 
 | ||||||
| echo 'testing good2...' | echo 'testing good2...' | ||||||
| $nixbuild fixed.nix -A good2 | nix-build fixed.nix -A good2 | ||||||
| 
 | 
 | ||||||
| echo 'testing bad...' | echo 'testing bad...' | ||||||
| $nixbuild fixed.nix -A bad && fail "should fail" | nix-build fixed.nix -A bad && fail "should fail" | ||||||
| 
 | 
 | ||||||
| echo 'testing reallyBad...' | echo 'testing reallyBad...' | ||||||
| $nixinstantiate fixed.nix -A reallyBad && fail "should fail" | nix-instantiate fixed.nix -A reallyBad && fail "should fail" | ||||||
| 
 | 
 | ||||||
| # While we're at it, check attribute selection a bit more. | # While we're at it, check attribute selection a bit more. | ||||||
| echo 'testing attribute selection...' | echo 'testing attribute selection...' | ||||||
| test $($nixinstantiate fixed.nix -A good.1 | wc -l) = 1 | test $(nix-instantiate fixed.nix -A good.1 | wc -l) = 1 | ||||||
| 
 | 
 | ||||||
| # Test parallel builds of derivations that produce the same output. | # Test parallel builds of derivations that produce the same output. | ||||||
| # Only one should run at the same time. | # Only one should run at the same time. | ||||||
| echo 'testing parallelSame...' | echo 'testing parallelSame...' | ||||||
| clearStore | clearStore | ||||||
| $nixbuild fixed.nix -A parallelSame -j2 | nix-build fixed.nix -A parallelSame -j2 | ||||||
| 
 | 
 | ||||||
| # Fixed-output derivations with a recursive SHA-256 hash should | # Fixed-output derivations with a recursive SHA-256 hash should | ||||||
| # produce the same path as "nix-store --add". | # produce the same path as "nix-store --add". | ||||||
| echo 'testing sameAsAdd...' | echo 'testing sameAsAdd...' | ||||||
| out=$($nixbuild fixed.nix -A sameAsAdd) | out=$(nix-build fixed.nix -A sameAsAdd) | ||||||
| 
 | 
 | ||||||
| # This is what fixed.builder2 produces... | # This is what fixed.builder2 produces... | ||||||
| rm -rf $TEST_ROOT/fixed | rm -rf $TEST_ROOT/fixed | ||||||
|  | @ -39,14 +39,14 @@ mkdir $TEST_ROOT/fixed/bla | ||||||
| echo "Hello World!" > $TEST_ROOT/fixed/foo | echo "Hello World!" > $TEST_ROOT/fixed/foo | ||||||
| ln -s foo $TEST_ROOT/fixed/bar | ln -s foo $TEST_ROOT/fixed/bar | ||||||
| 
 | 
 | ||||||
| out2=$($nixstore --add $TEST_ROOT/fixed) | out2=$(nix-store --add $TEST_ROOT/fixed) | ||||||
| echo $out2 | echo $out2 | ||||||
| test "$out" = "$out2" || exit 1 | test "$out" = "$out2" || exit 1 | ||||||
| 
 | 
 | ||||||
| out3=$($nixstore --add-fixed --recursive sha256 $TEST_ROOT/fixed) | out3=$(nix-store --add-fixed --recursive sha256 $TEST_ROOT/fixed) | ||||||
| echo $out3 | echo $out3 | ||||||
| test "$out" = "$out3" || exit 1 | test "$out" = "$out3" || exit 1 | ||||||
| 
 | 
 | ||||||
| out4=$($nixstore --print-fixed-path --recursive sha256 "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik" fixed) | out4=$(nix-store --print-fixed-path --recursive sha256 "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik" fixed) | ||||||
| echo $out4 | echo $out4 | ||||||
| test "$out" = "$out4" || exit 1 | test "$out" = "$out4" || exit 1 | ||||||
|  |  | ||||||
|  | @ -2,14 +2,14 @@ source common.sh | ||||||
| 
 | 
 | ||||||
| clearStore | clearStore | ||||||
| 
 | 
 | ||||||
| drvPath1=$($nixinstantiate gc-concurrent.nix -A test1) | drvPath1=$(nix-instantiate gc-concurrent.nix -A test1) | ||||||
| outPath1=$($nixstore -q $drvPath1) | outPath1=$(nix-store -q $drvPath1) | ||||||
| 
 | 
 | ||||||
| drvPath2=$($nixinstantiate gc-concurrent.nix -A test2) | drvPath2=$(nix-instantiate gc-concurrent.nix -A test2) | ||||||
| outPath2=$($nixstore -q $drvPath2) | outPath2=$(nix-store -q $drvPath2) | ||||||
| 
 | 
 | ||||||
| drvPath3=$($nixinstantiate simple.nix) | drvPath3=$(nix-instantiate simple.nix) | ||||||
| outPath3=$($nixstore -r $drvPath3) | outPath3=$(nix-store -r $drvPath3) | ||||||
| 
 | 
 | ||||||
| ! test -e $outPath3.lock | ! test -e $outPath3.lock | ||||||
| touch $outPath3.lock | touch $outPath3.lock | ||||||
|  | @ -19,16 +19,16 @@ ln -s $drvPath2 "$NIX_STATE_DIR"/gcroots/foo | ||||||
| ln -s $outPath3 "$NIX_STATE_DIR"/gcroots/foo2 | ln -s $outPath3 "$NIX_STATE_DIR"/gcroots/foo2 | ||||||
| 
 | 
 | ||||||
| # Start build #1 in the background.  It starts immediately. | # Start build #1 in the background.  It starts immediately. | ||||||
| $nixstore -rvv "$drvPath1" & | nix-store -rvv "$drvPath1" & | ||||||
| pid1=$! | pid1=$! | ||||||
| 
 | 
 | ||||||
| # Start build #2 in the background after 10 seconds. | # Start build #2 in the background after 10 seconds. | ||||||
| (sleep 10 && $nixstore -rvv "$drvPath2") & | (sleep 10 && nix-store -rvv "$drvPath2") & | ||||||
| pid2=$! | pid2=$! | ||||||
| 
 | 
 | ||||||
| # Run the garbage collector while the build is running. | # Run the garbage collector while the build is running. | ||||||
| sleep 6 | sleep 6 | ||||||
| $NIX_BIN_DIR/nix-collect-garbage | nix-collect-garbage | ||||||
| 
 | 
 | ||||||
| # Wait for build #1/#2 to finish. | # Wait for build #1/#2 to finish. | ||||||
| echo waiting for pid $pid1 to finish... | echo waiting for pid $pid1 to finish... | ||||||
|  | @ -53,6 +53,6 @@ rm -f "$NIX_STATE_DIR"/gcroots/foo* | ||||||
| ! test -e $outPath3.lock | ! test -e $outPath3.lock | ||||||
| 
 | 
 | ||||||
| # If we run the collector now, it should delete outPath1/2. | # If we run the collector now, it should delete outPath1/2. | ||||||
| $NIX_BIN_DIR/nix-collect-garbage | nix-collect-garbage | ||||||
| ! test -e $outPath1 | ! test -e $outPath1 | ||||||
| ! test -e $outPath2 | ! test -e $outPath2 | ||||||
|  |  | ||||||
|  | @ -12,9 +12,9 @@ set -m # enable job control, needed for kill | ||||||
| profiles="$NIX_STATE_DIR"/profiles | profiles="$NIX_STATE_DIR"/profiles | ||||||
| rm -f $profiles/* | rm -f $profiles/* | ||||||
| 
 | 
 | ||||||
| $nixenv -p $profiles/test -f ./gc-runtime.nix -i gc-runtime | nix-env -p $profiles/test -f ./gc-runtime.nix -i gc-runtime | ||||||
| 
 | 
 | ||||||
| outPath=$($nixenv -p $profiles/test -q --no-name --out-path gc-runtime) | outPath=$(nix-env -p $profiles/test -q --no-name --out-path gc-runtime) | ||||||
| echo $outPath | echo $outPath | ||||||
| 
 | 
 | ||||||
| echo "backgrounding program..." | echo "backgrounding program..." | ||||||
|  | @ -23,12 +23,12 @@ sleep 2 # hack - wait for the program to get started | ||||||
| child=$! | child=$! | ||||||
| echo PID=$child | echo PID=$child | ||||||
| 
 | 
 | ||||||
| $nixenv -p $profiles/test -e gc-runtime | nix-env -p $profiles/test -e gc-runtime | ||||||
| $nixenv -p $profiles/test --delete-generations old | nix-env -p $profiles/test --delete-generations old | ||||||
| 
 | 
 | ||||||
| cp $TOP/scripts/find-runtime-roots.pl $TEST_ROOT/foo.pl | cp $TOP/scripts/find-runtime-roots.pl $TEST_ROOT/foo.pl | ||||||
| chmod +x $TEST_ROOT/foo.pl | chmod +x $TEST_ROOT/foo.pl | ||||||
| NIX_ROOT_FINDER=$TEST_ROOT/foo.pl $nixstore --gc | NIX_ROOT_FINDER=$TEST_ROOT/foo.pl nix-store --gc | ||||||
| 
 | 
 | ||||||
| kill -- -$child | kill -- -$child | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										22
									
								
								tests/gc.sh
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								tests/gc.sh
									
										
									
									
									
								
							|  | @ -1,27 +1,27 @@ | ||||||
| source common.sh | source common.sh | ||||||
| 
 | 
 | ||||||
| drvPath=$($nixinstantiate dependencies.nix) | drvPath=$(nix-instantiate dependencies.nix) | ||||||
| outPath=$($nixstore -rvv "$drvPath") | outPath=$(nix-store -rvv "$drvPath") | ||||||
| 
 | 
 | ||||||
| # Set a GC root. | # Set a GC root. | ||||||
| rm -f "$NIX_STATE_DIR"/gcroots/foo | rm -f "$NIX_STATE_DIR"/gcroots/foo | ||||||
| ln -sf $outPath "$NIX_STATE_DIR"/gcroots/foo | ln -sf $outPath "$NIX_STATE_DIR"/gcroots/foo | ||||||
| 
 | 
 | ||||||
| $nixstore --gc --print-roots | grep $outPath | nix-store --gc --print-roots | grep $outPath | ||||||
| $nixstore --gc --print-live | grep $outPath | nix-store --gc --print-live | grep $outPath | ||||||
| $nixstore --gc --print-dead | grep $drvPath | nix-store --gc --print-dead | grep $drvPath | ||||||
| if $nixstore --gc --print-dead | grep $outPath; then false; fi | if nix-store --gc --print-dead | grep $outPath; then false; fi | ||||||
| 
 | 
 | ||||||
| $nixstore --gc --print-dead | nix-store --gc --print-dead | ||||||
| 
 | 
 | ||||||
| inUse=$(readLink $outPath/input-2) | inUse=$(readLink $outPath/input-2) | ||||||
| if $nixstore --delete $inUse; then false; fi | if nix-store --delete $inUse; then false; fi | ||||||
| test -e $inUse | test -e $inUse | ||||||
| 
 | 
 | ||||||
| if $nixstore --delete $outPath; then false; fi | if nix-store --delete $outPath; then false; fi | ||||||
| test -e $outPath | test -e $outPath | ||||||
| 
 | 
 | ||||||
| $NIX_BIN_DIR/nix-collect-garbage | nix-collect-garbage | ||||||
| 
 | 
 | ||||||
| # Check that the root and its dependencies haven't been deleted. | # Check that the root and its dependencies haven't been deleted. | ||||||
| cat $outPath/foobar | cat $outPath/foobar | ||||||
|  | @ -32,7 +32,7 @@ if test -e $drvPath; then false; fi | ||||||
| 
 | 
 | ||||||
| rm "$NIX_STATE_DIR"/gcroots/foo | rm "$NIX_STATE_DIR"/gcroots/foo | ||||||
| 
 | 
 | ||||||
| $NIX_BIN_DIR/nix-collect-garbage | nix-collect-garbage | ||||||
| 
 | 
 | ||||||
| # Check that the output has been GC'd. | # Check that the output has been GC'd. | ||||||
| if test -e $outPath/foobar; then false; fi | if test -e $outPath/foobar; then false; fi | ||||||
|  |  | ||||||
|  | @ -2,7 +2,7 @@ source common.sh | ||||||
| 
 | 
 | ||||||
| try () { | try () { | ||||||
|     printf "%s" "$2" > $TEST_ROOT/vector |     printf "%s" "$2" > $TEST_ROOT/vector | ||||||
|     hash=$($nixhash $EXTRA --flat --type "$1" $TEST_ROOT/vector) |     hash=$(nix-hash $EXTRA --flat --type "$1" $TEST_ROOT/vector) | ||||||
|     if test "$hash" != "$3"; then |     if test "$hash" != "$3"; then | ||||||
|         echo "hash $1, expected $3, got $hash" |         echo "hash $1, expected $3, got $hash" | ||||||
|         exit 1 |         exit 1 | ||||||
|  | @ -28,7 +28,7 @@ try sha256 "abc" "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s" | ||||||
| EXTRA= | EXTRA= | ||||||
| 
 | 
 | ||||||
| try2 () { | try2 () { | ||||||
|     hash=$($nixhash --type "$1" $TEST_ROOT/hash-path) |     hash=$(nix-hash --type "$1" $TEST_ROOT/hash-path) | ||||||
|     if test "$hash" != "$2"; then |     if test "$hash" != "$2"; then | ||||||
|         echo "hash $1, expected $2, got $hash" |         echo "hash $1, expected $2, got $hash" | ||||||
|         exit 1 |         exit 1 | ||||||
|  | @ -56,7 +56,7 @@ ln -s x $TEST_ROOT/hash-path/hello | ||||||
| try2 md5 "f78b733a68f5edbdf9413899339eaa4a" | try2 md5 "f78b733a68f5edbdf9413899339eaa4a" | ||||||
| 
 | 
 | ||||||
| # Conversion. | # Conversion. | ||||||
| test $($nixhash --type sha256 --to-base32 "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad") = "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s" | test $(nix-hash --type sha256 --to-base32 "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad") = "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s" | ||||||
| test $($nixhash --type sha256 --to-base16 "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s") = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" | test $(nix-hash --type sha256 --to-base16 "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s") = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" | ||||||
| test $($nixhash --type sha1 --to-base32 "800d59cfcd3c05e900cb4e214be48f6b886a08df") = "vw46m23bizj4n8afrc0fj19wrp7mj3c0" | test $(nix-hash --type sha1 --to-base32 "800d59cfcd3c05e900cb4e214be48f6b886a08df") = "vw46m23bizj4n8afrc0fj19wrp7mj3c0" | ||||||
| test $($nixhash --type sha1 --to-base16 "vw46m23bizj4n8afrc0fj19wrp7mj3c0") = "800d59cfcd3c05e900cb4e214be48f6b886a08df" | test $(nix-hash --type sha1 --to-base16 "vw46m23bizj4n8afrc0fj19wrp7mj3c0") = "800d59cfcd3c05e900cb4e214be48f6b886a08df" | ||||||
|  |  | ||||||
|  | @ -18,27 +18,19 @@ mkdir "$NIX_DB_DIR" | ||||||
| mkdir "$NIX_CONF_DIR" | mkdir "$NIX_CONF_DIR" | ||||||
| 
 | 
 | ||||||
| mkdir $NIX_BIN_DIR | mkdir $NIX_BIN_DIR | ||||||
| ln -s $nixstore $NIX_BIN_DIR/ | ln -s $TOP/src/nix-store/nix-store $NIX_BIN_DIR/ | ||||||
| ln -s $nixinstantiate $NIX_BIN_DIR/ | ln -s $TOP/src/nix-instantiate/nix-instantiate $NIX_BIN_DIR/ | ||||||
| ln -s $nixhash $NIX_BIN_DIR/ | ln -s $TOP/src/nix-hash/nix-hash $NIX_BIN_DIR/ | ||||||
| ln -s $nixenv $NIX_BIN_DIR/ | ln -s $TOP/src/nix-env/nix-env $NIX_BIN_DIR/ | ||||||
| ln -s $nixworker $NIX_BIN_DIR/ | ln -s $TOP/src/nix-worker/nix-worker $NIX_BIN_DIR/ | ||||||
| ln -s $TOP/src/bsdiff-*/bsdiff $NIX_BIN_DIR/ | ln -s $TOP/src/bsdiff-*/bsdiff $NIX_BIN_DIR/ | ||||||
| ln -s $TOP/src/bsdiff-*/bspatch $NIX_BIN_DIR/ | ln -s $TOP/src/bsdiff-*/bspatch $NIX_BIN_DIR/ | ||||||
| ln -s $TOP/scripts/nix-prefetch-url $NIX_BIN_DIR/ | ln -s $TOP/scripts/nix-prefetch-url $NIX_BIN_DIR/ | ||||||
| ln -s $TOP/scripts/nix-collect-garbage $NIX_BIN_DIR/ |  | ||||||
| ln -s $TOP/scripts/nix-build $NIX_BIN_DIR/ | ln -s $TOP/scripts/nix-build $NIX_BIN_DIR/ | ||||||
| ln -s $TOP/scripts/nix-install-package $NIX_BIN_DIR/ |  | ||||||
| ln -s $TOP/scripts/nix-push $NIX_BIN_DIR/ |  | ||||||
| ln -s $TOP/scripts/nix-pull $NIX_BIN_DIR/ | ln -s $TOP/scripts/nix-pull $NIX_BIN_DIR/ | ||||||
| ln -s $TOP/scripts/nix-generate-patches $NIX_BIN_DIR/ | mkdir -p $NIX_BIN_DIR/nix/substituters | ||||||
| mkdir $NIX_BIN_DIR/nix | ln -s $NIX_BZIP2 $NIX_BIN_DIR/nix/ | ||||||
| ln -s $bzip2_bin_test/bzip2 $NIX_BIN_DIR/nix/ | ln -s $TOP/scripts/copy-from-other-stores.pl $NIX_BIN_DIR/nix/substituters | ||||||
| ln -s $bzip2_bin_test/bunzip2 $NIX_BIN_DIR/nix/ |  | ||||||
| ln -s $TOP/scripts/copy-from-other-stores.pl $NIX_BIN_DIR/nix/ |  | ||||||
| ln -s $TOP/scripts/download-using-manifests.pl $NIX_BIN_DIR/nix/ |  | ||||||
| ln -s $TOP/scripts/GeneratePatches.pm $NIX_BIN_DIR/nix/ |  | ||||||
| ln -s $TOP/scripts/NixManifest.pm $NIX_BIN_DIR/nix/ |  | ||||||
| 
 | 
 | ||||||
| cat > "$NIX_CONF_DIR"/nix.conf <<EOF | cat > "$NIX_CONF_DIR"/nix.conf <<EOF | ||||||
| gc-keep-outputs = false | gc-keep-outputs = false | ||||||
|  | @ -53,17 +45,6 @@ cp -pr $TOP/corepkgs $NIX_DATA_DIR/nix/ | ||||||
| # (and likely to fail). | # (and likely to fail). | ||||||
| for i in \ | for i in \ | ||||||
|     $NIX_DATA_DIR/nix/corepkgs/nar/nar.sh \ |     $NIX_DATA_DIR/nix/corepkgs/nar/nar.sh \ | ||||||
|     $NIX_BIN_DIR/nix/download-using-manifests.pl \ |  | ||||||
|     $NIX_BIN_DIR/nix/copy-from-other-stores.pl \ |  | ||||||
|     $NIX_BIN_DIR/nix-prefetch-url \ |  | ||||||
|     $NIX_BIN_DIR/nix-collect-garbage \ |  | ||||||
|     $NIX_BIN_DIR/nix-build \ |  | ||||||
|     $NIX_BIN_DIR/nix-install-package \ |  | ||||||
|     $NIX_BIN_DIR/nix-push \ |  | ||||||
|     $NIX_BIN_DIR/nix-pull \ |  | ||||||
|     $NIX_BIN_DIR/nix-generate-patches \ |  | ||||||
|     $NIX_BIN_DIR/nix/NixManifest.pm \ |  | ||||||
|     $NIX_BIN_DIR/nix/GeneratePatches.pm \ |  | ||||||
|     ; do |     ; do | ||||||
|     sed < $i > $i.tmp \ |     sed < $i > $i.tmp \ | ||||||
|         -e "s^$REAL_BIN_DIR/nix-store^$NIX_BIN_DIR/nix-store^" \ |         -e "s^$REAL_BIN_DIR/nix-store^$NIX_BIN_DIR/nix-store^" \ | ||||||
|  | @ -87,20 +68,15 @@ mv tmp $NIX_DATA_DIR/nix/corepkgs/nar/nar.sh | ||||||
| # binaries sets DYLD_LIBRARY_PATH so that Perl finds Nix's (completely | # binaries sets DYLD_LIBRARY_PATH so that Perl finds Nix's (completely | ||||||
| # different) libutil --- so it barfs.  So generate a shell wrapper | # different) libutil --- so it barfs.  So generate a shell wrapper | ||||||
| # around download-using-manifests that clears DYLD_LIBRARY_PATH. | # around download-using-manifests that clears DYLD_LIBRARY_PATH. | ||||||
| mv $NIX_BIN_DIR/nix/download-using-manifests.pl $NIX_BIN_DIR/nix/download-using-manifests.pl.real | cat > $NIX_BIN_DIR/nix/substituters/download-using-manifests.pl <<EOF | ||||||
| cat > $NIX_BIN_DIR/nix/download-using-manifests.pl <<EOF |  | ||||||
| #! $SHELL -e | #! $SHELL -e | ||||||
| export DYLD_LIBRARY_PATH= | export DYLD_LIBRARY_PATH= | ||||||
| exec $NIX_BIN_DIR/nix/download-using-manifests.pl.real "\$@" | exec $TOP/scripts/download-using-manifests.pl "\$@" | ||||||
| EOF | EOF | ||||||
| chmod +x $NIX_BIN_DIR/nix/download-using-manifests.pl | chmod +x $NIX_BIN_DIR/nix/substituters/download-using-manifests.pl | ||||||
| 
 |  | ||||||
| mkdir -p $NIX_BIN_DIR/nix/substituters |  | ||||||
| mv $NIX_BIN_DIR/nix/copy-from-other-stores.pl $NIX_BIN_DIR/nix/substituters/copy-from-other-stores.pl |  | ||||||
| mv $NIX_BIN_DIR/nix/download-using-manifests.pl $NIX_BIN_DIR/nix/substituters/download-using-manifests.pl |  | ||||||
| 
 | 
 | ||||||
| # Initialise the database. | # Initialise the database. | ||||||
| $nixstore --init | nix-store --init | ||||||
| 
 | 
 | ||||||
| # Did anything happen? | # Did anything happen? | ||||||
| test -e "$NIX_DB_DIR"/db.sqlite | test -e "$NIX_DB_DIR"/db.sqlite | ||||||
|  |  | ||||||
|  | @ -2,8 +2,8 @@ source common.sh | ||||||
| 
 | 
 | ||||||
| # Note: this test expects to be run *after* nix-push.sh. | # Note: this test expects to be run *after* nix-push.sh. | ||||||
| 
 | 
 | ||||||
| drvPath=$($nixinstantiate ./dependencies.nix) | drvPath=$(nix-instantiate ./dependencies.nix) | ||||||
| outPath=$($nixstore -q $drvPath) | outPath=$(nix-store -q $drvPath) | ||||||
| 
 | 
 | ||||||
| clearStore | clearStore | ||||||
| clearProfiles | clearProfiles | ||||||
|  | @ -12,10 +12,10 @@ cat > $TEST_ROOT/foo.nixpkg <<EOF | ||||||
| NIXPKG1 file://$TEST_ROOT/manifest simple $system $drvPath $outPath | NIXPKG1 file://$TEST_ROOT/manifest simple $system $drvPath $outPath | ||||||
| EOF | EOF | ||||||
| 
 | 
 | ||||||
| $NIX_BIN_DIR/nix-install-package --non-interactive -p $profiles/test $TEST_ROOT/foo.nixpkg | nix-install-package --non-interactive -p $profiles/test $TEST_ROOT/foo.nixpkg | ||||||
| test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1 | test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1 | ||||||
| 
 | 
 | ||||||
| clearProfiles | clearProfiles | ||||||
| 
 | 
 | ||||||
| $NIX_BIN_DIR/nix-install-package --non-interactive -p $profiles/test --url file://$TEST_ROOT/foo.nixpkg | nix-install-package --non-interactive -p $profiles/test --url file://$TEST_ROOT/foo.nixpkg | ||||||
| test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1 | test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1 | ||||||
|  |  | ||||||
|  | @ -7,7 +7,7 @@ fail=0 | ||||||
| for i in lang/parse-fail-*.nix; do | for i in lang/parse-fail-*.nix; do | ||||||
|     echo "parsing $i (should fail)"; |     echo "parsing $i (should fail)"; | ||||||
|     i=$(basename $i .nix) |     i=$(basename $i .nix) | ||||||
|     if $nixinstantiate --parse-only - < lang/$i.nix; then |     if nix-instantiate --parse-only - < lang/$i.nix; then | ||||||
|         echo "FAIL: $i shouldn't parse" |         echo "FAIL: $i shouldn't parse" | ||||||
|         fail=1 |         fail=1 | ||||||
|     fi |     fi | ||||||
|  | @ -16,7 +16,7 @@ done | ||||||
| for i in lang/parse-okay-*.nix; do | for i in lang/parse-okay-*.nix; do | ||||||
|     echo "parsing $i (should succeed)"; |     echo "parsing $i (should succeed)"; | ||||||
|     i=$(basename $i .nix) |     i=$(basename $i .nix) | ||||||
|     if ! $nixinstantiate --parse-only - < lang/$i.nix > lang/$i.out; then |     if ! nix-instantiate --parse-only - < lang/$i.nix > lang/$i.out; then | ||||||
|         echo "FAIL: $i should parse" |         echo "FAIL: $i should parse" | ||||||
|         fail=1 |         fail=1 | ||||||
|     fi |     fi | ||||||
|  | @ -25,7 +25,7 @@ done | ||||||
| for i in lang/eval-fail-*.nix; do | for i in lang/eval-fail-*.nix; do | ||||||
|     echo "evaluating $i (should fail)"; |     echo "evaluating $i (should fail)"; | ||||||
|     i=$(basename $i .nix) |     i=$(basename $i .nix) | ||||||
|     if $nixinstantiate --eval-only lang/$i.nix; then |     if nix-instantiate --eval-only lang/$i.nix; then | ||||||
|         echo "FAIL: $i shouldn't evaluate" |         echo "FAIL: $i shouldn't evaluate" | ||||||
|         fail=1 |         fail=1 | ||||||
|     fi |     fi | ||||||
|  | @ -40,7 +40,7 @@ for i in lang/eval-okay-*.nix; do | ||||||
|         if test -e lang/$i.flags; then |         if test -e lang/$i.flags; then | ||||||
|             flags=$(cat lang/$i.flags) |             flags=$(cat lang/$i.flags) | ||||||
|         fi |         fi | ||||||
|         if ! NIX_PATH=lang/dir3:lang/dir4 $nixinstantiate $flags --eval-only --strict lang/$i.nix > lang/$i.out; then |         if ! NIX_PATH=lang/dir3:lang/dir4 nix-instantiate $flags --eval-only --strict lang/$i.nix > lang/$i.out; then | ||||||
|             echo "FAIL: $i should evaluate" |             echo "FAIL: $i should evaluate" | ||||||
|             fail=1 |             fail=1 | ||||||
|         elif ! diff lang/$i.out lang/$i.exp; then |         elif ! diff lang/$i.out lang/$i.exp; then | ||||||
|  | @ -50,7 +50,7 @@ for i in lang/eval-okay-*.nix; do | ||||||
|     fi |     fi | ||||||
|      |      | ||||||
|     if test -e lang/$i.exp.xml; then |     if test -e lang/$i.exp.xml; then | ||||||
|         if ! $nixinstantiate --eval-only --xml --no-location --strict \ |         if ! nix-instantiate --eval-only --xml --no-location --strict \ | ||||||
|                 lang/$i.nix > lang/$i.out.xml; then |                 lang/$i.nix > lang/$i.out.xml; then | ||||||
|             echo "FAIL: $i should evaluate" |             echo "FAIL: $i should evaluate" | ||||||
|             fail=1 |             fail=1 | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ clearStore | ||||||
| 
 | 
 | ||||||
| # Produce an escaped log file. | # Produce an escaped log file. | ||||||
| set -x | set -x | ||||||
| $nixbuild --log-type escapes -vv dependencies.nix 2> $TEST_ROOT/log.esc | nix-build --log-type escapes -vv dependencies.nix 2> $TEST_ROOT/log.esc | ||||||
| 
 | 
 | ||||||
| # Convert it to an XML representation. | # Convert it to an XML representation. | ||||||
| $TOP/src/nix-log2xml/nix-log2xml < $TEST_ROOT/log.esc > $TEST_ROOT/log.xml | $TOP/src/nix-log2xml/nix-log2xml < $TEST_ROOT/log.esc > $TEST_ROOT/log.xml | ||||||
|  |  | ||||||
|  | @ -3,14 +3,14 @@ source common.sh | ||||||
| # Tests miscellaneous commands. | # Tests miscellaneous commands. | ||||||
| 
 | 
 | ||||||
| # Do all commands have help? | # Do all commands have help? | ||||||
| $nixenv --help | grep -q install | nix-env --help | grep -q install | ||||||
| $nixstore --help | grep -q realise | nix-store --help | grep -q realise | ||||||
| $nixinstantiate --help | grep -q eval-only | nix-instantiate --help | grep -q eval-only | ||||||
| $nixhash --help | grep -q base32 | nix-hash --help | grep -q base32 | ||||||
| 
 | 
 | ||||||
| # Can we ask for the version number? | # Can we ask for the version number? | ||||||
| $nixenv --version | grep "$version" | nix-env --version | grep "$version" | ||||||
| 
 | 
 | ||||||
| # Usage errors. | # Usage errors. | ||||||
| $nixenv --foo 2>&1 | grep "no operation" | nix-env --foo 2>&1 | grep "no operation" | ||||||
| $nixenv -q --foo 2>&1 | grep "unknown flag" | nix-env -q --foo 2>&1 | grep "unknown flag" | ||||||
|  |  | ||||||
|  | @ -7,16 +7,16 @@ set +e | ||||||
| opts="--option build-cache-failure true --print-build-trace" | opts="--option build-cache-failure true --print-build-trace" | ||||||
| 
 | 
 | ||||||
| # This build should fail, and the failure should be cached. | # This build should fail, and the failure should be cached. | ||||||
| log=$($nixbuild $opts negative-caching.nix -A fail 2>&1) && fail "should fail" | log=$(nix-build $opts negative-caching.nix -A fail 2>&1) && fail "should fail" | ||||||
| echo "$log" | grep -q "@ build-failed" || fail "no build-failed trace" | echo "$log" | grep -q "@ build-failed" || fail "no build-failed trace" | ||||||
| 
 | 
 | ||||||
| # Do it again.  The build shouldn't be tried again. | # Do it again.  The build shouldn't be tried again. | ||||||
| log=$($nixbuild $opts negative-caching.nix -A fail 2>&1) && fail "should fail" | log=$(nix-build $opts negative-caching.nix -A fail 2>&1) && fail "should fail" | ||||||
| echo "$log" | grep -q "FAIL" && fail "failed build not cached" | echo "$log" | grep -q "FAIL" && fail "failed build not cached" | ||||||
| echo "$log" | grep -q "@ build-failed .* cached" || fail "trace doesn't say cached" | echo "$log" | grep -q "@ build-failed .* cached" || fail "trace doesn't say cached" | ||||||
| 
 | 
 | ||||||
| # Check that --keep-going works properly with cached failures. | # Check that --keep-going works properly with cached failures. | ||||||
| log=$($nixbuild $opts --keep-going negative-caching.nix -A depOnFail 2>&1) && fail "should fail" | log=$(nix-build $opts --keep-going negative-caching.nix -A depOnFail 2>&1) && fail "should fail" | ||||||
| echo "$log" | grep -q "FAIL" && fail "failed build not cached (2)" | echo "$log" | grep -q "FAIL" && fail "failed build not cached (2)" | ||||||
| echo "$log" | grep -q "@ build-failed .* cached" || fail "trace doesn't say cached (2)" | echo "$log" | grep -q "@ build-failed .* cached" || fail "trace doesn't say cached (2)" | ||||||
| echo "$log" | grep -q "@ build-succeeded .*-succeed" || fail "didn't keep going" | echo "$log" | grep -q "@ build-succeeded .*-succeed" || fail "didn't keep going" | ||||||
|  |  | ||||||
|  | @ -2,7 +2,7 @@ source common.sh | ||||||
| 
 | 
 | ||||||
| clearStore | clearStore | ||||||
| 
 | 
 | ||||||
| (cd $TEST_ROOT && $nixbuild ../dependencies.nix) | (cd $TEST_ROOT && nix-build ../dependencies.nix) | ||||||
| test "$(cat $TEST_ROOT/result/foobar)" = FOOBAR | test "$(cat $TEST_ROOT/result/foobar)" = FOOBAR | ||||||
| 
 | 
 | ||||||
| # The result should be retained by a GC. | # The result should be retained by a GC. | ||||||
|  | @ -10,10 +10,10 @@ echo A | ||||||
| target=$(readLink $TEST_ROOT/result) | target=$(readLink $TEST_ROOT/result) | ||||||
| echo B | echo B | ||||||
| echo target is $target | echo target is $target | ||||||
| $nixstore --gc | nix-store --gc | ||||||
| test -e $target/foobar | test -e $target/foobar | ||||||
| 
 | 
 | ||||||
| # But now it should be gone. | # But now it should be gone. | ||||||
| rm $TEST_ROOT/result | rm $TEST_ROOT/result | ||||||
| $nixstore --gc | nix-store --gc | ||||||
| if test -e $target/foobar; then false; fi | if test -e $target/foobar; then false; fi | ||||||
|  |  | ||||||
							
								
								
									
										54
									
								
								tests/nix-copy-closure.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								tests/nix-copy-closure.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,54 @@ | ||||||
|  | # Test ‘nix-copy-closure’. | ||||||
|  | 
 | ||||||
|  | { nixpkgs, nixos, system, nix }: | ||||||
|  | 
 | ||||||
|  | with import "${nixos}/lib/testing.nix" { inherit nixpkgs system; }; | ||||||
|  | 
 | ||||||
|  | makeTest ({ pkgs, ... }: let pkgA = pkgs.aterm; pkgB = pkgs.wget; in { | ||||||
|  | 
 | ||||||
|  |   nodes = | ||||||
|  |     { client = | ||||||
|  |         { config, pkgs, ... }: | ||||||
|  |         { virtualisation.writableStore = true; | ||||||
|  |           virtualisation.pathsInNixDB = [ pkgA ]; | ||||||
|  |           environment.nix = nix; | ||||||
|  |         }; | ||||||
|  |          | ||||||
|  |       server = | ||||||
|  |         { config, pkgs, ... }: | ||||||
|  |         { services.openssh.enable = true; | ||||||
|  |           virtualisation.writableStore = true; | ||||||
|  |           virtualisation.pathsInNixDB = [ pkgB ]; | ||||||
|  |           environment.nix = nix; | ||||||
|  |         };         | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|  |   testScript = { nodes }: | ||||||
|  |     '' | ||||||
|  |       startAll; | ||||||
|  | 
 | ||||||
|  |       # Create an SSH key on the client. | ||||||
|  |       my $key = `${pkgs.openssh}/bin/ssh-keygen -t dsa -f key -N ""`; | ||||||
|  |       $client->succeed("mkdir -m 700 /root/.ssh"); | ||||||
|  |       $client->copyFileFromHost("key", "/root/.ssh/id_dsa"); | ||||||
|  |       $client->succeed("chmod 600 /root/.ssh/id_dsa"); | ||||||
|  | 
 | ||||||
|  |       # Install the SSH key on the server. | ||||||
|  |       $server->succeed("mkdir -m 700 /root/.ssh"); | ||||||
|  |       $server->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys"); | ||||||
|  |       $server->waitForJob("sshd"); | ||||||
|  |       $client->waitForJob("network-interfaces"); | ||||||
|  |       $client->succeed("ssh -o StrictHostKeyChecking=no " . $server->name() . " 'echo hello world'"); | ||||||
|  | 
 | ||||||
|  |       # Copy the closure of package A from the client to the server. | ||||||
|  |       $server->fail("nix-store --check-validity ${pkgA}"); | ||||||
|  |       $client->succeed("nix-copy-closure --to server --gzip ${pkgA} >&2"); | ||||||
|  |       $server->succeed("nix-store --check-validity ${pkgA}"); | ||||||
|  | 
 | ||||||
|  |       # Copy the closure of package B from the server to the client. | ||||||
|  |       $client->fail("nix-store --check-validity ${pkgB}"); | ||||||
|  |       $client->succeed("nix-copy-closure --from server --gzip ${pkgB} >&2"); | ||||||
|  |       $client->succeed("nix-store --check-validity ${pkgB}"); | ||||||
|  |     ''; | ||||||
|  | 
 | ||||||
|  | }) | ||||||
|  | @ -2,18 +2,18 @@ source common.sh | ||||||
| 
 | 
 | ||||||
| pullCache () { | pullCache () { | ||||||
|     echo "pulling cache..." |     echo "pulling cache..." | ||||||
|     $NIX_BIN_DIR/nix-pull file://$TEST_ROOT/manifest |     nix-pull file://$TEST_ROOT/manifest | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| clearStore | clearStore | ||||||
| clearManifests | clearManifests | ||||||
| pullCache | pullCache | ||||||
| 
 | 
 | ||||||
| drvPath=$($nixinstantiate dependencies.nix) | drvPath=$(nix-instantiate dependencies.nix) | ||||||
| outPath=$($nixstore -q $drvPath) | outPath=$(nix-store -q $drvPath) | ||||||
| 
 | 
 | ||||||
| echo "building $outPath using substitutes..." | echo "building $outPath using substitutes..." | ||||||
| $nixstore -r $outPath | nix-store -r $outPath | ||||||
| 
 | 
 | ||||||
| cat $outPath/input-2/bar | cat $outPath/input-2/bar | ||||||
| 
 | 
 | ||||||
|  | @ -22,12 +22,12 @@ clearManifests | ||||||
| pullCache | pullCache | ||||||
| 
 | 
 | ||||||
| echo "building $drvPath using substitutes..." | echo "building $drvPath using substitutes..." | ||||||
| $nixstore -r $drvPath | nix-store -r $drvPath | ||||||
| 
 | 
 | ||||||
| cat $outPath/input-2/bar | cat $outPath/input-2/bar | ||||||
| 
 | 
 | ||||||
| # Check that the derivers are set properly. | # Check that the derivers are set properly. | ||||||
| test $($nixstore -q --deriver "$outPath") = "$drvPath" | test $(nix-store -q --deriver "$outPath") = "$drvPath" | ||||||
| $nixstore -q --deriver $(readLink $outPath/input-2) | grep -q -- "-input-2.drv"  | nix-store -q --deriver $(readLink $outPath/input-2) | grep -q -- "-input-2.drv"  | ||||||
| 
 | 
 | ||||||
| clearManifests | clearManifests | ||||||
|  |  | ||||||
|  | @ -1,11 +1,10 @@ | ||||||
| source common.sh | source common.sh | ||||||
| 
 | 
 | ||||||
| drvPath=$($nixinstantiate dependencies.nix) | drvPath=$(nix-instantiate dependencies.nix) | ||||||
| outPath=$($nixstore -r $drvPath) | outPath=$(nix-store -r $drvPath) | ||||||
| 
 | 
 | ||||||
| echo "pushing $drvPath" | echo "pushing $drvPath" | ||||||
| 
 | 
 | ||||||
| mkdir -p $TEST_ROOT/cache | mkdir -p $TEST_ROOT/cache | ||||||
| 
 | 
 | ||||||
| $NIX_BIN_DIR/nix-push \ | nix-push --copy $TEST_ROOT/cache $TEST_ROOT/manifest $drvPath | ||||||
|     --copy $TEST_ROOT/cache $TEST_ROOT/manifest $drvPath |  | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ clearStore | ||||||
| 
 | 
 | ||||||
| rm -f $SHARED.cur $SHARED.max | rm -f $SHARED.cur $SHARED.max | ||||||
| 
 | 
 | ||||||
| outPath=$($nixbuild -j10000 parallel.nix) | outPath=$(nix-build -j10000 parallel.nix) | ||||||
| 
 | 
 | ||||||
| echo "output path is $outPath" | echo "output path is $outPath" | ||||||
| 
 | 
 | ||||||
|  | @ -27,9 +27,9 @@ clearStore | ||||||
| 
 | 
 | ||||||
| rm -f $SHARED.cur $SHARED.max | rm -f $SHARED.cur $SHARED.max | ||||||
| 
 | 
 | ||||||
| drvPath=$($nixinstantiate parallel.nix --argstr sleepTime 15) | drvPath=$(nix-instantiate parallel.nix --argstr sleepTime 15) | ||||||
| 
 | 
 | ||||||
| cmd="$nixstore -j1 -r $drvPath" | cmd="nix-store -j1 -r $drvPath" | ||||||
| 
 | 
 | ||||||
| $cmd & | $cmd & | ||||||
| pid1=$! | pid1=$! | ||||||
|  |  | ||||||
|  | @ -6,7 +6,7 @@ max=500 | ||||||
| 
 | 
 | ||||||
| reference=$NIX_STORE_DIR/abcdef | reference=$NIX_STORE_DIR/abcdef | ||||||
| touch $reference | touch $reference | ||||||
| (echo $reference && echo && echo 0) | $nixstore --register-validity  | (echo $reference && echo && echo 0) | nix-store --register-validity  | ||||||
| 
 | 
 | ||||||
| echo "making registration..." | echo "making registration..." | ||||||
| 
 | 
 | ||||||
|  | @ -22,11 +22,11 @@ done > $TEST_ROOT/reg_info | ||||||
| 
 | 
 | ||||||
| echo "registering..." | echo "registering..." | ||||||
| 
 | 
 | ||||||
| $nixstore --register-validity < $TEST_ROOT/reg_info | nix-store --register-validity < $TEST_ROOT/reg_info | ||||||
| 
 | 
 | ||||||
| echo "collecting garbage..." | echo "collecting garbage..." | ||||||
| ln -sfn $reference "$NIX_STATE_DIR"/gcroots/ref | ln -sfn $reference "$NIX_STATE_DIR"/gcroots/ref | ||||||
| $nixstore --gc | nix-store --gc | ||||||
| 
 | 
 | ||||||
| if test "$(sqlite3 ./test-tmp/db/db.sqlite 'select count(*) from Refs')" -ne 0; then | if test "$(sqlite3 ./test-tmp/db/db.sqlite 'select count(*) from Refs')" -ne 0; then | ||||||
|     echo "referrers not cleaned up" |     echo "referrers not cleaned up" | ||||||
|  |  | ||||||
							
								
								
									
										97
									
								
								tests/remote-builds.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								tests/remote-builds.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,97 @@ | ||||||
|  | # Test Nix's remote build feature. | ||||||
|  | 
 | ||||||
|  | { nixpkgs, nixos, system, nix }: | ||||||
|  | 
 | ||||||
|  | with import "${nixos}/lib/testing.nix" { inherit nixpkgs system; }; | ||||||
|  | 
 | ||||||
|  | makeTest ({ pkgs, ... }: | ||||||
|  | 
 | ||||||
|  | let | ||||||
|  | 
 | ||||||
|  |   # The configuration of the build slaves. | ||||||
|  |   slave = | ||||||
|  |     { config, pkgs, ... }: | ||||||
|  |     { services.openssh.enable = true; | ||||||
|  |       virtualisation.writableStore = true; | ||||||
|  |       environment.nix = nix; | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|  |   # Trivial Nix expression to build remotely. | ||||||
|  |   expr = config: nr: pkgs.writeText "expr.nix" | ||||||
|  |     '' | ||||||
|  |       let utils = builtins.storePath ${config.system.build.extraUtils}; in | ||||||
|  |       derivation { | ||||||
|  |         name = "hello-${toString nr}"; | ||||||
|  |         system = "i686-linux"; | ||||||
|  |         PATH = "''${utils}/bin"; | ||||||
|  |         builder = "''${utils}/bin/sh"; | ||||||
|  |         args = [ "-c" "echo Hello; mkdir $out; cat /proc/sys/kernel/hostname > $out/host; sleep 3" ]; | ||||||
|  |       } | ||||||
|  |     ''; | ||||||
|  | 
 | ||||||
|  | in | ||||||
|  | 
 | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  |   nodes = | ||||||
|  |     { slave1 = slave; | ||||||
|  |       slave2 = slave; | ||||||
|  | 
 | ||||||
|  |       client = | ||||||
|  |         { config, pkgs, ... }: | ||||||
|  |         { nix.maxJobs = 0; # force remote building | ||||||
|  |           nix.distributedBuilds = true; | ||||||
|  |           nix.buildMachines = | ||||||
|  |             [ { hostName = "slave1"; | ||||||
|  |                 sshUser = "root"; | ||||||
|  |                 sshKey = "/root/.ssh/id_dsa"; | ||||||
|  |                 system = "i686-linux"; | ||||||
|  |                 maxJobs = 1; | ||||||
|  |               } | ||||||
|  |               { hostName = "slave2"; | ||||||
|  |                 sshUser = "root"; | ||||||
|  |                 sshKey = "/root/.ssh/id_dsa"; | ||||||
|  |                 system = "i686-linux"; | ||||||
|  |                 maxJobs = 1; | ||||||
|  |               } | ||||||
|  |             ]; | ||||||
|  |           virtualisation.writableStore = true; | ||||||
|  |           virtualisation.pathsInNixDB = [ config.system.build.extraUtils ]; | ||||||
|  |           environment.nix = nix; | ||||||
|  |         }; | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|  |   testScript = { nodes }: | ||||||
|  |     '' | ||||||
|  |       startAll; | ||||||
|  | 
 | ||||||
|  |       # Create an SSH key on the client. | ||||||
|  |       my $key = `${pkgs.openssh}/bin/ssh-keygen -t dsa -f key -N ""`; | ||||||
|  |       $client->succeed("mkdir -m 700 /root/.ssh"); | ||||||
|  |       $client->copyFileFromHost("key", "/root/.ssh/id_dsa"); | ||||||
|  |       $client->succeed("chmod 600 /root/.ssh/id_dsa"); | ||||||
|  | 
 | ||||||
|  |       # Install the SSH key on the slaves. | ||||||
|  |       foreach my $slave ($slave1, $slave2) { | ||||||
|  |           $slave->succeed("mkdir -m 700 /root/.ssh"); | ||||||
|  |           $slave->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys"); | ||||||
|  |           $slave->waitForJob("sshd"); | ||||||
|  |           $client->succeed("ssh -o StrictHostKeyChecking=no " . $slave->name() . " 'echo hello world'"); | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       # Perform a build and check that it was performed on the slave. | ||||||
|  |       my $out = $client->succeed("nix-build ${expr nodes.client.config 1}"); | ||||||
|  |       $slave1->succeed("test -e $out"); | ||||||
|  | 
 | ||||||
|  |       # And a parallel build. | ||||||
|  |       my ($out1, $out2) = split /\s/, | ||||||
|  |           $client->succeed("nix-store -r \$(nix-instantiate ${expr nodes.client.config 2} ${expr nodes.client.config 3})"); | ||||||
|  |       $slave1->succeed("test -e $out1 -o -e $out2"); | ||||||
|  |       $slave2->succeed("test -e $out1 -o -e $out2"); | ||||||
|  | 
 | ||||||
|  |       # Test whether the build hook automatically skips unavailable slaves. | ||||||
|  |       $slave1->block; | ||||||
|  |       $client->succeed("nix-build ${expr nodes.client.config 4}"); | ||||||
|  |     ''; | ||||||
|  | 
 | ||||||
|  | }) | ||||||
|  | @ -10,11 +10,11 @@ clearManifests | ||||||
| startDaemon | startDaemon | ||||||
| 
 | 
 | ||||||
| # Determine the output path of the "good" derivation. | # Determine the output path of the "good" derivation. | ||||||
| goodOut=$($nixstore -q $($nixinstantiate ./secure-drv-outputs.nix -A good)) | goodOut=$(nix-store -q $(nix-instantiate ./secure-drv-outputs.nix -A good)) | ||||||
| 
 | 
 | ||||||
| # Instantiate the "bad" derivation. | # Instantiate the "bad" derivation. | ||||||
| badDrv=$($nixinstantiate ./secure-drv-outputs.nix -A bad) | badDrv=$(nix-instantiate ./secure-drv-outputs.nix -A bad) | ||||||
| badOut=$($nixstore -q $badDrv) | badOut=$(nix-store -q $badDrv) | ||||||
| 
 | 
 | ||||||
| # Rewrite the bad derivation to produce the output path of the good | # Rewrite the bad derivation to produce the output path of the good | ||||||
| # derivation. | # derivation. | ||||||
|  | @ -23,12 +23,12 @@ sed -e "s|$badOut|$goodOut|g" < $badDrv > $TEST_ROOT/bad.drv | ||||||
| 
 | 
 | ||||||
| # Add the manipulated derivation to the store and build it.  This | # Add the manipulated derivation to the store and build it.  This | ||||||
| # should fail. | # should fail. | ||||||
| if badDrv2=$($nixstore --add $TEST_ROOT/bad.drv); then | if badDrv2=$(nix-store --add $TEST_ROOT/bad.drv); then | ||||||
|     $nixstore -r "$badDrv2" |     nix-store -r "$badDrv2" | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| # Now build the good derivation. | # Now build the good derivation. | ||||||
| goodOut2=$($nixbuild ./secure-drv-outputs.nix -A good) | goodOut2=$(nix-build ./secure-drv-outputs.nix -A good) | ||||||
| test "$goodOut" = "$goodOut2" | test "$goodOut" = "$goodOut2" | ||||||
| 
 | 
 | ||||||
| if ! test -e "$goodOut"/good; then | if ! test -e "$goodOut"/good; then | ||||||
|  |  | ||||||
|  | @ -1,12 +1,12 @@ | ||||||
| source common.sh | source common.sh | ||||||
| 
 | 
 | ||||||
| drvPath=$($nixinstantiate simple.nix) | drvPath=$(nix-instantiate simple.nix) | ||||||
| 
 | 
 | ||||||
| test "$($nixstore -q --binding system "$drvPath")" = "$system" | test "$(nix-store -q --binding system "$drvPath")" = "$system" | ||||||
| 
 | 
 | ||||||
| echo "derivation is $drvPath" | echo "derivation is $drvPath" | ||||||
| 
 | 
 | ||||||
| outPath=$($nixstore -rvv "$drvPath") | outPath=$(nix-store -rvv "$drvPath") | ||||||
| 
 | 
 | ||||||
| echo "output path is $outPath" | echo "output path is $outPath" | ||||||
| 
 | 
 | ||||||
|  | @ -15,10 +15,10 @@ if test "$text" != "Hello World!"; then exit 1; fi | ||||||
| 
 | 
 | ||||||
| # Directed delete: $outPath is not reachable from a root, so it should | # Directed delete: $outPath is not reachable from a root, so it should | ||||||
| # be deleteable. | # be deleteable. | ||||||
| $nixstore --delete $outPath | nix-store --delete $outPath | ||||||
| if test -e $outPath/hello; then false; fi | if test -e $outPath/hello; then false; fi | ||||||
| 
 | 
 | ||||||
| outPath="$(NIX_STORE_DIR=/foo $nixinstantiate --readonly-mode hash-check.nix)" | outPath="$(NIX_STORE_DIR=/foo nix-instantiate --readonly-mode hash-check.nix)" | ||||||
| if test "$outPath" != "/foo/lfy1s6ca46rm5r6w4gg9hc0axiakjcnm-dependencies.drv"; then | if test "$outPath" != "/foo/lfy1s6ca46rm5r6w4gg9hc0axiakjcnm-dependencies.drv"; then | ||||||
|     echo "hashDerivationModulo appears broken, got $outPath" |     echo "hashDerivationModulo appears broken, got $outPath" | ||||||
|     exit 1 |     exit 1 | ||||||
|  |  | ||||||
|  | @ -3,20 +3,20 @@ source common.sh | ||||||
| clearStore | clearStore | ||||||
| 
 | 
 | ||||||
| # Instantiate. | # Instantiate. | ||||||
| drvPath=$($nixinstantiate simple.nix) | drvPath=$(nix-instantiate simple.nix) | ||||||
| echo "derivation is $drvPath" | echo "derivation is $drvPath" | ||||||
| 
 | 
 | ||||||
| # Find the output path. | # Find the output path. | ||||||
| outPath=$($nixstore -qvv "$drvPath") | outPath=$(nix-store -qvv "$drvPath") | ||||||
| echo "output path is $outPath" | echo "output path is $outPath" | ||||||
| 
 | 
 | ||||||
| echo $outPath > $TEST_ROOT/sub-paths | echo $outPath > $TEST_ROOT/sub-paths | ||||||
| 
 | 
 | ||||||
| export NIX_SUBSTITUTERS=$(pwd)/substituter.sh | export NIX_SUBSTITUTERS=$(pwd)/substituter.sh | ||||||
| 
 | 
 | ||||||
| $nixstore -r "$drvPath" --dry-run 2>&1 | grep -q "1.00 MiB.*2.00 MiB" | nix-store -r "$drvPath" --dry-run 2>&1 | grep -q "1.00 MiB.*2.00 MiB" | ||||||
| 
 | 
 | ||||||
| $nixstore -rvv "$drvPath" | nix-store -rvv "$drvPath" | ||||||
| 
 | 
 | ||||||
| text=$(cat "$outPath"/hello) | text=$(cat "$outPath"/hello) | ||||||
| if test "$text" != "Hallo Wereld"; then echo "wrong substitute output: $text"; exit 1; fi | if test "$text" != "Hallo Wereld"; then echo "wrong substitute output: $text"; exit 1; fi | ||||||
|  |  | ||||||
|  | @ -3,11 +3,11 @@ source common.sh | ||||||
| clearStore | clearStore | ||||||
| 
 | 
 | ||||||
| # Instantiate. | # Instantiate. | ||||||
| drvPath=$($nixinstantiate simple.nix) | drvPath=$(nix-instantiate simple.nix) | ||||||
| echo "derivation is $drvPath" | echo "derivation is $drvPath" | ||||||
| 
 | 
 | ||||||
| # Find the output path. | # Find the output path. | ||||||
| outPath=$($nixstore -qvvvvv "$drvPath") | outPath=$(nix-store -qvvvvv "$drvPath") | ||||||
| echo "output path is $outPath" | echo "output path is $outPath" | ||||||
| 
 | 
 | ||||||
| echo $outPath > $TEST_ROOT/sub-paths | echo $outPath > $TEST_ROOT/sub-paths | ||||||
|  | @ -15,7 +15,7 @@ echo $outPath > $TEST_ROOT/sub-paths | ||||||
| # First try a substituter that fails, then one that succeeds | # First try a substituter that fails, then one that succeeds | ||||||
| export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh:$(pwd)/substituter.sh | export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh:$(pwd)/substituter.sh | ||||||
| 
 | 
 | ||||||
| $nixstore -j0 -rvv "$drvPath" | nix-store -j0 -rvv "$drvPath" | ||||||
| 
 | 
 | ||||||
| text=$(cat "$outPath"/hello) | text=$(cat "$outPath"/hello) | ||||||
| if test "$text" != "Hallo Wereld"; then echo "wrong substitute output: $text"; exit 1; fi | if test "$text" != "Hallo Wereld"; then echo "wrong substitute output: $text"; exit 1; fi | ||||||
|  |  | ||||||
|  | @ -2,14 +2,14 @@ | ||||||
| 
 | 
 | ||||||
| source common.sh | source common.sh | ||||||
| 
 | 
 | ||||||
| drvPath=$($nixinstantiate timeout.nix) | drvPath=$(nix-instantiate timeout.nix) | ||||||
| 
 | 
 | ||||||
| test "$($nixstore -q --binding system "$drvPath")" = "$system" | test "$(nix-store -q --binding system "$drvPath")" = "$system" | ||||||
| 
 | 
 | ||||||
| echo "derivation is $drvPath" | echo "derivation is $drvPath" | ||||||
| 
 | 
 | ||||||
| failed=0 | failed=0 | ||||||
| messages="`$nixstore -r --timeout 2 $drvPath 2>&1 || failed=1`" | messages="`nix-store -r --timeout 2 $drvPath 2>&1 || failed=1`" | ||||||
| if test $failed -ne 0; then | if test $failed -ne 0; then | ||||||
|     echo "error: \`nix-store' succeeded; should have timed out" >&2 |     echo "error: \`nix-store' succeeded; should have timed out" >&2 | ||||||
|     exit 1 |     exit 1 | ||||||
|  |  | ||||||
|  | @ -5,110 +5,110 @@ clearProfiles | ||||||
| set -x | set -x | ||||||
| 
 | 
 | ||||||
| # Query installed: should be empty. | # Query installed: should be empty. | ||||||
| test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 0 | test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 0 | ||||||
| 
 | 
 | ||||||
| # Query available: should contain several. | # Query available: should contain several. | ||||||
| test "$($nixenv -p $profiles/test -f ./user-envs.nix -qa '*' | wc -l)" -eq 5 | test "$(nix-env -p $profiles/test -f ./user-envs.nix -qa '*' | wc -l)" -eq 5 | ||||||
| 
 | 
 | ||||||
| # Query descriptions. | # Query descriptions. | ||||||
| $nixenv -p $profiles/test -f ./user-envs.nix -qa '*' --description | grep silly | nix-env -p $profiles/test -f ./user-envs.nix -qa '*' --description | grep silly | ||||||
| 
 | 
 | ||||||
| # Install "foo-1.0". | # Install "foo-1.0". | ||||||
| $nixenv -p $profiles/test -f ./user-envs.nix -i foo-1.0 | nix-env -p $profiles/test -f ./user-envs.nix -i foo-1.0 | ||||||
| 
 | 
 | ||||||
| # Query installed: should contain foo-1.0 now (which should be | # Query installed: should contain foo-1.0 now (which should be | ||||||
| # executable). | # executable). | ||||||
| test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1 | test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1 | ||||||
| $nixenv -p $profiles/test -q '*' | grep -q foo-1.0 | nix-env -p $profiles/test -q '*' | grep -q foo-1.0 | ||||||
| test "$($profiles/test/bin/foo)" = "foo-1.0" | test "$($profiles/test/bin/foo)" = "foo-1.0" | ||||||
| 
 | 
 | ||||||
| # Store the path of foo-1.0. | # Store the path of foo-1.0. | ||||||
| outPath10=$($nixenv -p $profiles/test -q --out-path --no-name '*' | grep foo-1.0) | outPath10=$(nix-env -p $profiles/test -q --out-path --no-name '*' | grep foo-1.0) | ||||||
| echo "foo-1.0 = $outPath10" | echo "foo-1.0 = $outPath10" | ||||||
| test -n "$outPath10" | test -n "$outPath10" | ||||||
| 
 | 
 | ||||||
| # Install "foo-2.0pre1": should remove foo-1.0. | # Install "foo-2.0pre1": should remove foo-1.0. | ||||||
| $nixenv -p $profiles/test -f ./user-envs.nix -i foo-2.0pre1 | nix-env -p $profiles/test -f ./user-envs.nix -i foo-2.0pre1 | ||||||
| 
 | 
 | ||||||
| # Query installed: should contain foo-2.0pre1 now. | # Query installed: should contain foo-2.0pre1 now. | ||||||
| test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1 | test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1 | ||||||
| $nixenv -p $profiles/test -q '*' | grep -q foo-2.0pre1 | nix-env -p $profiles/test -q '*' | grep -q foo-2.0pre1 | ||||||
| test "$($profiles/test/bin/foo)" = "foo-2.0pre1" | test "$($profiles/test/bin/foo)" = "foo-2.0pre1" | ||||||
| 
 | 
 | ||||||
| # Upgrade "foo": should install foo-2.0. | # Upgrade "foo": should install foo-2.0. | ||||||
| $nixenv -p $profiles/test -f ./user-envs.nix -u foo | nix-env -p $profiles/test -f ./user-envs.nix -u foo | ||||||
| 
 | 
 | ||||||
| # Query installed: should contain foo-2.0 now. | # Query installed: should contain foo-2.0 now. | ||||||
| test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1 | test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1 | ||||||
| $nixenv -p $profiles/test -q '*' | grep -q foo-2.0 | nix-env -p $profiles/test -q '*' | grep -q foo-2.0 | ||||||
| test "$($profiles/test/bin/foo)" = "foo-2.0" | test "$($profiles/test/bin/foo)" = "foo-2.0" | ||||||
| 
 | 
 | ||||||
| # Store the path of foo-2.0. | # Store the path of foo-2.0. | ||||||
| outPath20=$($nixenv -p $profiles/test -q --out-path --no-name '*' | grep foo-2.0) | outPath20=$(nix-env -p $profiles/test -q --out-path --no-name '*' | grep foo-2.0) | ||||||
| test -n "$outPath20" | test -n "$outPath20" | ||||||
| 
 | 
 | ||||||
| # Install bar-0.1, uninstall foo. | # Install bar-0.1, uninstall foo. | ||||||
| $nixenv -p $profiles/test -f ./user-envs.nix -i bar-0.1 | nix-env -p $profiles/test -f ./user-envs.nix -i bar-0.1 | ||||||
| $nixenv -p $profiles/test -f ./user-envs.nix -e foo | nix-env -p $profiles/test -f ./user-envs.nix -e foo | ||||||
| 
 | 
 | ||||||
| # Query installed: should only contain bar-0.1 now. | # Query installed: should only contain bar-0.1 now. | ||||||
| if $nixenv -p $profiles/test -q '*' | grep -q foo; then false; fi | if nix-env -p $profiles/test -q '*' | grep -q foo; then false; fi | ||||||
| $nixenv -p $profiles/test -q '*' | grep -q bar | nix-env -p $profiles/test -q '*' | grep -q bar | ||||||
| 
 | 
 | ||||||
| # Rollback: should bring "foo" back. | # Rollback: should bring "foo" back. | ||||||
| $nixenv -p $profiles/test --rollback | nix-env -p $profiles/test --rollback | ||||||
| $nixenv -p $profiles/test -q '*' | grep -q foo-2.0 | nix-env -p $profiles/test -q '*' | grep -q foo-2.0 | ||||||
| $nixenv -p $profiles/test -q '*' | grep -q bar | nix-env -p $profiles/test -q '*' | grep -q bar | ||||||
| 
 | 
 | ||||||
| # Rollback again: should remove "bar". | # Rollback again: should remove "bar". | ||||||
| $nixenv -p $profiles/test --rollback | nix-env -p $profiles/test --rollback | ||||||
| $nixenv -p $profiles/test -q '*' | grep -q foo-2.0 | nix-env -p $profiles/test -q '*' | grep -q foo-2.0 | ||||||
| if $nixenv -p $profiles/test -q '*' | grep -q bar; then false; fi | if nix-env -p $profiles/test -q '*' | grep -q bar; then false; fi | ||||||
| 
 | 
 | ||||||
| # Count generations. | # Count generations. | ||||||
| $nixenv -p $profiles/test --list-generations | nix-env -p $profiles/test --list-generations | ||||||
| test "$($nixenv -p $profiles/test --list-generations | wc -l)" -eq 5 | test "$(nix-env -p $profiles/test --list-generations | wc -l)" -eq 5 | ||||||
| 
 | 
 | ||||||
| # Install foo-1.0, now using its store path. | # Install foo-1.0, now using its store path. | ||||||
| echo $outPath10 | echo $outPath10 | ||||||
| $nixenv -p $profiles/test -i "$outPath10" | nix-env -p $profiles/test -i "$outPath10" | ||||||
| $nixenv -p $profiles/test -q '*' | grep -q foo-1.0 | nix-env -p $profiles/test -q '*' | grep -q foo-1.0 | ||||||
| 
 | 
 | ||||||
| # Uninstall foo-1.0, using a symlink to its store path. | # Uninstall foo-1.0, using a symlink to its store path. | ||||||
| ln -sfn $outPath10/bin/foo $TEST_ROOT/symlink | ln -sfn $outPath10/bin/foo $TEST_ROOT/symlink | ||||||
| $nixenv -p $profiles/test -e $TEST_ROOT/symlink | nix-env -p $profiles/test -e $TEST_ROOT/symlink | ||||||
| if $nixenv -p $profiles/test -q '*' | grep -q foo; then false; fi | if nix-env -p $profiles/test -q '*' | grep -q foo; then false; fi | ||||||
| 
 | 
 | ||||||
| # Install foo-1.0, now using a symlink to its store path. | # Install foo-1.0, now using a symlink to its store path. | ||||||
| $nixenv -p $profiles/test -i $TEST_ROOT/symlink | nix-env -p $profiles/test -i $TEST_ROOT/symlink | ||||||
| $nixenv -p $profiles/test -q '*' | grep -q foo | nix-env -p $profiles/test -q '*' | grep -q foo | ||||||
| 
 | 
 | ||||||
| # Delete all old generations. | # Delete all old generations. | ||||||
| $nixenv -p $profiles/test --delete-generations old | nix-env -p $profiles/test --delete-generations old | ||||||
| 
 | 
 | ||||||
| # Run the garbage collector.  This should get rid of foo-2.0 but not | # Run the garbage collector.  This should get rid of foo-2.0 but not | ||||||
| # foo-1.0. | # foo-1.0. | ||||||
| $NIX_BIN_DIR/nix-collect-garbage | nix-collect-garbage | ||||||
| test -e "$outPath10" | test -e "$outPath10" | ||||||
| if test -e "$outPath20"; then false; fi | if test -e "$outPath20"; then false; fi | ||||||
| 
 | 
 | ||||||
| # Uninstall everything | # Uninstall everything | ||||||
| $nixenv -p $profiles/test -f ./user-envs.nix -e '*' | nix-env -p $profiles/test -f ./user-envs.nix -e '*' | ||||||
| test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 0 | test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 0 | ||||||
| 
 | 
 | ||||||
| # Installing "foo" should only install the newest foo. | # Installing "foo" should only install the newest foo. | ||||||
| $nixenv -p $profiles/test -f ./user-envs.nix -i foo | nix-env -p $profiles/test -f ./user-envs.nix -i foo | ||||||
| test "$($nixenv -p $profiles/test -q '*' | grep foo- | wc -l)" -eq 1 | test "$(nix-env -p $profiles/test -q '*' | grep foo- | wc -l)" -eq 1 | ||||||
| $nixenv -p $profiles/test -q '*' | grep -q foo-2.0 | nix-env -p $profiles/test -q '*' | grep -q foo-2.0 | ||||||
| 
 | 
 | ||||||
| # On the other hand, this should install both (and should fail due to | # On the other hand, this should install both (and should fail due to | ||||||
| # a collision). | # a collision). | ||||||
| $nixenv -p $profiles/test -f ./user-envs.nix -e '*' | nix-env -p $profiles/test -f ./user-envs.nix -e '*' | ||||||
| if $nixenv -p $profiles/test -f ./user-envs.nix -i foo-1.0 foo-2.0; then false; fi | if nix-env -p $profiles/test -f ./user-envs.nix -i foo-1.0 foo-2.0; then false; fi | ||||||
| 
 | 
 | ||||||
| # Installing "*" should install one foo and one bar. | # Installing "*" should install one foo and one bar. | ||||||
| $nixenv -p $profiles/test -f ./user-envs.nix -e '*' | nix-env -p $profiles/test -f ./user-envs.nix -e '*' | ||||||
| $nixenv -p $profiles/test -f ./user-envs.nix -i '*' | nix-env -p $profiles/test -f ./user-envs.nix -i '*' | ||||||
| test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 2 | test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 2 | ||||||
| $nixenv -p $profiles/test -q '*' | grep -q foo-2.0 | nix-env -p $profiles/test -q '*' | grep -q foo-2.0 | ||||||
| $nixenv -p $profiles/test -q '*' | grep -q bar-0.1.1 | nix-env -p $profiles/test -q '*' | grep -q bar-0.1.1 | ||||||
|  |  | ||||||
|  | @ -1,3 +1,3 @@ | ||||||
| source common.sh | source common.sh | ||||||
| 
 | 
 | ||||||
| $nixstore --verify | nix-store --verify | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue