about summary refs log tree commit diff
path: root/scripts/nix-push.in
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2011-02-17T13·26+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2011-02-17T13·26+0000
commite945b52a31ab339b253df40e35828582eff77e54 (patch)
tree2ebea842b4a51695396144f334a532b23f7619ed /scripts/nix-push.in
parentc3cee5395bec0dd9db3fb60662a170ebb7453ee1 (diff)
* nix-push: handle the case where the hash is not set in the DB.
Diffstat (limited to 'scripts/nix-push.in')
-rw-r--r--scripts/nix-push.in10
1 files changed, 10 insertions, 0 deletions
diff --git a/scripts/nix-push.in b/scripts/nix-push.in
index 1d8ba86a8d0c..fa83f92c8eaa 100644
--- a/scripts/nix-push.in
+++ b/scripts/nix-push.in
@@ -193,6 +193,16 @@ for (my $n = 0; $n < scalar @storePaths; $n++) {
     die "cannot query hash for `$storePath'" if $? != 0;
     chomp $narHash;
 
+    # In some exceptional cases (such as VM tests that use the Nix
+    # store of the host), the database doesn't contain the hash.  So
+    # compute it.
+    if ($narHash eq "sha256:0000000000000000000000000000000000000000000000000000000000000000") {
+        $narHash = `$binDir/nix-hash --type sha256 '$storePath'`;
+        die "cannot hash `$storePath'" if $? != 0;
+        chomp $narHash;
+        $narHash = "sha256:$narHash";
+    }
+
     my $narSize = `$binDir/nix-store --query --size '$storePath'`;
     die "cannot query size for `$storePath'" if $? != 0;
     chomp $narSize;