about summary refs log tree commit diff
path: root/corepkgs/fetchurl
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-08-15T10·13+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-08-15T10·13+0000
commite374dbf89b0ba9a4f5835ef9ac30eda6df1dce6a (patch)
treeab3712823c18dcb08fd4506716b4a102b7cfdc8b /corepkgs/fetchurl
parent01e30360d46ce940d8b83f4ff7a71e8464c1422b (diff)
* A script `nix-prefetch-url' to fetch a URL, place it in the Nix
  store, and print its hash.

Diffstat (limited to 'corepkgs/fetchurl')
-rw-r--r--corepkgs/fetchurl/fetchurl.sh.in11
1 files changed, 10 insertions, 1 deletions
diff --git a/corepkgs/fetchurl/fetchurl.sh.in b/corepkgs/fetchurl/fetchurl.sh.in
index 7e876a25e2aa..88e4d81f2e48 100644
--- a/corepkgs/fetchurl/fetchurl.sh.in
+++ b/corepkgs/fetchurl/fetchurl.sh.in
@@ -1,7 +1,16 @@
 #! /bin/sh
 
+export PATH=/bin:/usr/bin
+
 echo "downloading $url into $out..."
-@wget@ "$url" -O "$out" || exit 1
+
+prefetch=@prefix@/store/nix-prefetch-url-$md5
+if test -f "$prefetch"; then
+    echo "using prefetched $prefetch";
+    mv $prefetch $out || exit 1
+else
+    @wget@ "$url" -O "$out" || exit 1
+fi
 
 actual=$(@bindir@/nix-hash --flat $out)
 if test "$actual" != "$md5"; then