summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-07-11 15:48:05 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-07-11 15:52:35 +0200
commit267c8d6b2fea05bc811c8e2c2f4529b1436eeb9a (patch)
tree8043beb00c3ee4fd7bddadcfa7c41bbfded3b3b7 /pkgs
parent528a6902938d45f97bf41699a717245ecf52902a (diff)
downloadnixpkgs-267c8d6b2fea05bc811c8e2c2f4529b1436eeb9a.tar
nixpkgs-267c8d6b2fea05bc811c8e2c2f4529b1436eeb9a.tar.gz
nixpkgs-267c8d6b2fea05bc811c8e2c2f4529b1436eeb9a.tar.bz2
nixpkgs-267c8d6b2fea05bc811c8e2c2f4529b1436eeb9a.tar.lz
nixpkgs-267c8d6b2fea05bc811c8e2c2f4529b1436eeb9a.tar.xz
nixpkgs-267c8d6b2fea05bc811c8e2c2f4529b1436eeb9a.tar.zst
nixpkgs-267c8d6b2fea05bc811c8e2c2f4529b1436eeb9a.zip
fetchurl (and derived functions): Support SRI hashes
E.g.

  fetchFromGitHub {
    owner = "NixOS";
    repo = "nix";
    rev = "ad42a784690449873fccb20192bd2150da81c56d";
    hash = "sha256-ZXeadXUJMXV5lSLz6TOBeL/SSOVwQ8ywxU5AFMCnbRU=";
  }
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/build-support/fetchurl/default.nix10
1 files changed, 7 insertions, 3 deletions
diff --git a/pkgs/build-support/fetchurl/default.nix b/pkgs/build-support/fetchurl/default.nix
index 3ce90cbeab3..6300587a7d1 100644
--- a/pkgs/build-support/fetchurl/default.nix
+++ b/pkgs/build-support/fetchurl/default.nix
@@ -49,8 +49,11 @@ in
   # first element of `urls').
   name ? ""
 
-  # Different ways of specifying the hash.
-, outputHash ? ""
+, # SRI hash.
+  hash ? ""
+
+, # Legacy ways of specifying the hash.
+  outputHash ? ""
 , outputHashAlgo ? ""
 , md5 ? ""
 , sha1 ? ""
@@ -103,7 +106,8 @@ let
     else throw "fetchurl requires either `url` or `urls` to be set";
 
   hash_ =
-    if md5 != "" then throw "fetchurl does not support md5 anymore, please use sha256 or sha512"
+    if hash != "" then { outputHashAlgo = null; outputHash = hash; }
+    else if md5 != "" then throw "fetchurl does not support md5 anymore, please use sha256 or sha512"
     else if (outputHash != "" && outputHashAlgo != "") then { inherit outputHashAlgo outputHash; }
     else if sha512 != "" then { outputHashAlgo = "sha512"; outputHash = sha512; }
     else if sha256 != "" then { outputHashAlgo = "sha256"; outputHash = sha256; }