diff options
author | Vladimír Čunát <v@cunat.cz> | 2022-07-26 12:45:00 +0200 |
---|---|---|
committer | Vladimír Čunát <v@cunat.cz> | 2022-07-26 12:47:14 +0200 |
commit | cb704bf922aac3032a8bd98d73d708197fa661d9 (patch) | |
tree | 0baafa3d67c2dfcda3a059efbefb708175a8486c | |
parent | 59d13713c21c4a38d8bc06eafbc5e8a8cb6a3139 (diff) | |
download | nixpkgs-cb704bf922aac3032a8bd98d73d708197fa661d9.tar nixpkgs-cb704bf922aac3032a8bd98d73d708197fa661d9.tar.gz nixpkgs-cb704bf922aac3032a8bd98d73d708197fa661d9.tar.bz2 nixpkgs-cb704bf922aac3032a8bd98d73d708197fa661d9.tar.lz nixpkgs-cb704bf922aac3032a8bd98d73d708197fa661d9.tar.xz nixpkgs-cb704bf922aac3032a8bd98d73d708197fa661d9.tar.zst nixpkgs-cb704bf922aac3032a8bd98d73d708197fa661d9.zip |
fetchurl: disallow specifying both `sha256` and `hash`
A full check would be more complicated to write - and more importantly - probably also more expensive. Motivation: eval-time catch for errors like in commit 8198636be07e4.
-rw-r--r-- | pkgs/build-support/fetchurl/default.nix | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/pkgs/build-support/fetchurl/default.nix b/pkgs/build-support/fetchurl/default.nix index 7ec831c61ac..a85d53adb82 100644 --- a/pkgs/build-support/fetchurl/default.nix +++ b/pkgs/build-support/fetchurl/default.nix @@ -117,6 +117,9 @@ let else throw "fetchurl requires either `url` or `urls` to be set"; hash_ = + # Many other combinations don't make sense, but this is the most common one: + if hash != "" && sha256 != "" then throw "multiple hashes passed to fetchurl" else + 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; } |