fetchurl: Validate that a single hash was passed

nicoo a59f0307 182d23ab

+2 -2
+2 -2
pkgs/build-support/fetchurl/default.nix
··· 120 120 else throw "fetchurl requires either `url` or `urls` to be set"; 121 121 122 122 hash_ = 123 - # Many other combinations don't make sense, but this is the most common one: 124 - if hash != "" && sha256 != "" then throw "multiple hashes passed to fetchurl" else 123 + if with lib.lists; length (filter (s: s != "") [ hash outputHash sha1 sha256 sha512 ]) > 1 124 + then throw "multiple hashes passed to fetchurl" else 125 125 126 126 if hash != "" then { outputHashAlgo = null; outputHash = hash; } 127 127 else if (outputHash != "" && outputHashAlgo != "") then { inherit outputHashAlgo outputHash; }