about summary refs log tree commit diff
path: root/corepkgs
diff options
context:
space:
mode:
Diffstat (limited to 'corepkgs')
-rw-r--r--corepkgs/fetchurl/builder.sh.in8
-rw-r--r--corepkgs/fetchurl/default.nix19
2 files changed, 18 insertions, 9 deletions
diff --git a/corepkgs/fetchurl/builder.sh.in b/corepkgs/fetchurl/builder.sh.in
index c1a735d68fef..aaba65d6d26c 100644
--- a/corepkgs/fetchurl/builder.sh.in
+++ b/corepkgs/fetchurl/builder.sh.in
@@ -4,16 +4,10 @@ export PATH=/bin:/usr/bin
 
 echo "downloading $url into $out"
 
-prefetch=@storedir@/nix-prefetch-url-$md5
+prefetch=@storedir@/nix-prefetch-url-$outputHash
 if test -f "$prefetch"; then
     echo "using prefetched $prefetch";
     mv $prefetch $out
 else
     @curl@ --fail --location --max-redirs 20 "$url" > "$out"
 fi
-
-actual=$(@bindir@/nix-hash --flat $out)
-if test "$actual" != "$md5"; then
-    echo "hash is $actual, expected $md5"
-    exit 1
-fi
diff --git a/corepkgs/fetchurl/default.nix b/corepkgs/fetchurl/default.nix
index 8957662eccab..37f01b55eeb0 100644
--- a/corepkgs/fetchurl/default.nix
+++ b/corepkgs/fetchurl/default.nix
@@ -1,8 +1,23 @@
-{system, url, md5}:
+# Argh, this thing is duplicated (more-or-less) in Nixpkgs.  Need to
+# find a way to combine them.
+
+{system, url, outputHash ? "", outputHashAlgo ? "", md5 ? "", sha1 ? "", sha256 ? ""}:
+
+assert (outputHash != "" && outputHashAlgo != "")
+    || md5 != "" || sha1 != "" || sha256 != "";
 
 derivation {
   name = baseNameOf (toString url);
   builder = ./builder.sh;
+
+  # Compatibility with Nix <= 0.7.
   id = md5;
-  inherit system url md5;
+
+  # New-style output content requirements.
+  outputHashAlgo = if outputHashAlgo != "" then outputHashAlgo else
+      if sha256 != "" then "sha256" else if sha1 != "" then "sha1" else "md5";
+  outputHash = if outputHash != "" then outputHash else
+      if sha256 != "" then sha256 else if sha1 != "" then sha1 else md5;
+  
+  inherit system url;
 }