about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-09-20T15·04+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-09-20T15·04+0000
commita060adf165e24a585da0301e88ad41e674f3e9db (patch)
tree6558ef430fb13b36bc0e3b1090833a610b5bacd3 /scripts
parent7dd342e482b230d0042f8f2dee6ccb44232a3d3b (diff)
* Use paths, not strings, when calling the function that generates
  NARs.  Fixes the impurity of nix-push (NIX-21).
* Better help.

Diffstat (limited to 'scripts')
-rw-r--r--scripts/nix-push.in27
1 files changed, 17 insertions, 10 deletions
diff --git a/scripts/nix-push.in b/scripts/nix-push.in
index c27e813b48e8..283d78a6117e 100644
--- a/scripts/nix-push.in
+++ b/scripts/nix-push.in
@@ -37,8 +37,22 @@ my $archivesPutURL;
 my $archivesGetURL;
 my $manifestPutURL;
 
+sub showSyntax {
+    print STDERR <<EOF
+Usage: nix-push --copy ARCHIVES_DIR MANIFEST_FILE PATHS...
+   or: nix-push ARCHIVES_PUT_URL ARCHIVES_GET_URL MANIFEST_PUT_URL PATHS...
+
+`nix-push' copies or uploads the closure of PATHS to the given
+destination.
+EOF
+    ; # `
+    exit 1;
+}
+
+showSyntax if scalar @ARGV < 1;
+
 if ($ARGV[0] eq "--copy") {
-    die "syntax: nix-push --copy ARCHIVES_DIR MANIFEST_FILE PATHS...\n" if scalar @ARGV < 3;
+    showSyntax if scalar @ARGV < 3;
     $localCopy = 1;
     shift @ARGV;
     $localArchivesDir = shift @ARGV;
@@ -52,8 +66,7 @@ if ($ARGV[0] eq "--copy") {
     }
 }
 else {
-    die "syntax: nix-push ARCHIVES_PUT_URL ARCHIVES_GET_URL " .
-        "MANIFEST_PUT_URL PATHS...\n" if scalar @ARGV < 3;
+    showSyntax if scalar @ARGV < 3;
     $localCopy = 0;
     $archivesPutURL = shift @ARGV;
     $archivesGetURL = shift @ARGV;
@@ -95,15 +108,9 @@ foreach my $storePath (@storePaths) {
     die unless ($storePath =~ /\/[0-9a-z]{32}.*$/);
 
     # Construct a Nix expression that creates a Nix archive.
-    # !!! the string reference to `$storePath' is impure!  We could
-    # also pass it as a normal input, but that would cause it to be
-    # copied, and its name would be expanded (e.g.,
-    # /nix/store/HASH1-HASH2-symname).  nix-instantiate should be
-    # smart enough to add store paths as direct references of the Nix
-    # expression.
     my $nixexpr = 
         "((import $dataDir/nix/corepkgs/nar/nar.nix) " .
-        "{storePath = \"$storePath\"; system = \"@system@\"; hashAlgo = \"$hashAlgo\";}) ";
+        "{storePath = $storePath; system = \"@system@\"; hashAlgo = \"$hashAlgo\";}) ";
     
     print NIX $nixexpr;
 }