about summary refs log tree commit diff
path: root/scripts/nix-push.in
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/nix-push.in')
-rwxr-xr-xscripts/nix-push.in32
1 files changed, 20 insertions, 12 deletions
diff --git a/scripts/nix-push.in b/scripts/nix-push.in
index 39fdd6da9e39..1edd8e77314b 100755
--- a/scripts/nix-push.in
+++ b/scripts/nix-push.in
@@ -61,7 +61,7 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
         push @roots, $arg;
     }
 }
-        
+
 showSyntax if !defined $destDir;
 
 $archivesURL = "file://$destDir" unless defined $archivesURL;
@@ -74,12 +74,12 @@ my %storePaths;
 foreach my $path (@roots) {
     die unless $path =~ /^\//;
 
-    # Get all paths referenced by the normalisation of the given 
+    # Get all paths referenced by the normalisation of the given
     # Nix expression.
     my $pid = open(READ,
         "$Nix::Config::binDir/nix-store --query --requisites --force-realise " .
         "--include-outputs '$path'|") or die;
-    
+
     while (<READ>) {
         chomp;
         die "bad: $_" unless /^\//;
@@ -101,10 +101,10 @@ foreach my $storePath (@storePaths) {
     die unless ($storePath =~ /\/[0-9a-z]{32}[^\"\\\$]*$/);
 
     # Construct a Nix expression that creates a Nix archive.
-    my $nixexpr = 
+    my $nixexpr =
         "(import <nix/nar.nix> " .
         "{ storePath = builtins.storePath \"$storePath\"; hashAlgo = \"sha256\"; compressionType = \"$compressionType\"; }) ";
-    
+
     print NIX $nixexpr;
 }
 
@@ -125,7 +125,17 @@ while (<READ>) {
 close READ or die "nix-build failed: $?";
 
 
-# Copy the archives and the corresponding info files.
+# Write the cache info file.
+my $cacheInfoFile = "$destDir/nix-cache-info";
+if (! -e $cacheInfoFile) {
+    open FILE, ">$cacheInfoFile" or die "cannot create $cacheInfoFile: $!";
+    print FILE "StoreDir: $Nix::Config::storeDir\n";
+    print FILE "WantMassQuery: 0\n"; # by default, don't hit this cache for "nix-env -qas"
+    close FILE;
+}
+
+
+# Copy the archives and the corresponding NAR info files.
 print STDERR "copying archives...\n";
 
 my $totalNarSize = 0;
@@ -157,7 +167,7 @@ for (my $n = 0; $n < scalar @storePaths; $n++) {
     }
 
     $totalNarSize += $narSize;
-    
+
     # Get info about the compressed NAR.
     open HASH, "$narDir/nar-compressed-hash" or die "cannot open nar-compressed-hash";
     my $compressedHash = <HASH>;
@@ -170,7 +180,7 @@ for (my $n = 0; $n < scalar @storePaths; $n++) {
     my $narFile = "$narDir/$narName";
     (-f $narFile) or die "NAR file for $storePath not found";
 
-    my $compressedSize = stat($narFile)->size;    
+    my $compressedSize = stat($narFile)->size;
     $totalCompressedSize += $compressedSize;
 
     printf STDERR "%s [%.2f MiB, %.1f%%]\n", $storePath,
@@ -203,7 +213,7 @@ for (my $n = 0; $n < scalar @storePaths; $n++) {
     }
 
     my $pathHash = substr(basename($storePath), 0, 32);
-    
+
     $dst = "$destDir/$pathHash.narinfo";
     if ($force || ! -f $dst) {
         my $tmp = "$destDir/.tmp.$$.$pathHash.narinfo";
@@ -230,6 +240,4 @@ printf STDERR "total compressed size %.2f MiB, %.1f%%\n",
 
 
 # Optionally write a manifest.
-if ($writeManifest) {
-    writeManifest "$destDir/MANIFEST", \%narFiles, \();
-}
+writeManifest "$destDir/MANIFEST", \%narFiles, \() if $writeManifest;