about summary refs log tree commit diff
path: root/scripts/nix-prefetch-url.in
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2011-10-10T21·11+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2011-10-10T21·11+0000
commit6fcdbcac202e40e5de7147ff64b34d6aaad16249 (patch)
tree3a18b2cde295fd1551bedb279948660dccd22d60 /scripts/nix-prefetch-url.in
parent659c427caa39e44e5861ff1345425e4c34c9ced3 (diff)
* Install NixManifest.pm, NixConfig.pm and GeneratePatches.pm under
  the Nix:: namespace.

Diffstat (limited to 'scripts/nix-prefetch-url.in')
-rw-r--r--scripts/nix-prefetch-url.in17
1 files changed, 10 insertions, 7 deletions
diff --git a/scripts/nix-prefetch-url.in b/scripts/nix-prefetch-url.in
index 31170fa953ea..45bad75f3e9f 100644
--- a/scripts/nix-prefetch-url.in
+++ b/scripts/nix-prefetch-url.in
@@ -3,6 +3,9 @@
 url=$1
 expHash=$2
 
+binDir=@bindir@
+if [ -n "$NIX_BIN_DIR" ]; then binDir="$NIX_BIN_DIR"; fi
+
 # needed to make it work on NixOS
 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
 # store.
 if test -n "$expHash"; then
-    finalPath=$(@bindir@/nix-store --print-fixed-path "$hashType" "$expHash" "$name")
-    if ! @bindir@/nix-store --check-validity "$finalPath" 2> /dev/null; then
+    finalPath=$($binDir/nix-store --print-fixed-path "$hashType" "$expHash" "$name")
+    if ! $bindir/nix-store --check-validity "$finalPath" 2> /dev/null; then
         finalPath=
     fi
     hash=$expHash
@@ -103,7 +106,7 @@ if test -z "$finalPath"; then
     # garbage-collected independently.
     if test -n "$NIX_DOWNLOAD_CACHE"; then
         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"
         cachedHashFN="$NIX_DOWNLOAD_CACHE/$urlHash.$hashType"
         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
         # file on the server.
         hash=$(cat $cachedHashFN)
-        finalPath=$(@bindir@/nix-store --print-fixed-path "$hashType" "$hash" "$name") 
-        if ! @bindir@/nix-store --check-validity "$finalPath" 2> /dev/null; then
+        finalPath=$($binDir/nix-store --print-fixed-path "$hashType" "$hash" "$name") 
+        if ! $binDir/nix-store --check-validity "$finalPath" 2> /dev/null; then
             echo "cached contents of \`$url' disappeared, redownloading..." >&2
             finalPath=
             cacheFlags="--remote-time"
@@ -133,7 +136,7 @@ if test -z "$finalPath"; then
     if test -z "$finalPath"; then
 
         # 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 "$NIX_DOWNLOAD_CACHE"; then
@@ -142,7 +145,7 @@ if test -z "$finalPath"; then
         fi
 
         # 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
             echo "hash mismatch for URL \`$url'" >&2