diff options
author | Maciej Krüger <mkg20001@gmail.com> | 2023-09-09 00:55:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-09 00:55:19 +0200 |
commit | 614640665323e75dfa0299152a04352b6e7d7dda (patch) | |
tree | 6c234a7865c9e2d1e6d8c2346762a9f7250177d8 /pkgs/build-support | |
parent | 88aa035e6c43619ce9dcfb17cd3a88944d12ea75 (diff) | |
parent | af5682b3e1ced9d3f764a548ee7e1459fbcc5969 (diff) |
Merge pull request #252343 from nbraud/fetchurl/hashValidation
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/fetchurl/default.nix | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pkgs/build-support/fetchurl/default.nix b/pkgs/build-support/fetchurl/default.nix index d1a886a34a701..a9c2c7c46d14d 100644 --- a/pkgs/build-support/fetchurl/default.nix +++ b/pkgs/build-support/fetchurl/default.nix @@ -120,11 +120,13 @@ 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 with lib.lists; length (filter (s: s != "") [ hash outputHash sha1 sha256 sha512 ]) > 1 + then throw "multiple hashes passed to fetchurl" else if hash != "" then { outputHashAlgo = null; outputHash = hash; } - else if (outputHash != "" && outputHashAlgo != "") then { inherit outputHashAlgo outputHash; } + else if outputHash != "" then + if outputHashAlgo != "" then { inherit outputHashAlgo outputHash; } + else throw "fetchurl was passed outputHash without outputHashAlgo" else if sha512 != "" then { outputHashAlgo = "sha512"; outputHash = sha512; } else if sha256 != "" then { outputHashAlgo = "sha256"; outputHash = sha256; } else if sha1 != "" then { outputHashAlgo = "sha1"; outputHash = sha1; } |