Merge pull request #247111 from K900/requirefile-fix-error-message

requireFile: fix error message with SRI hashes
This commit is contained in:
K900 2023-08-05 21:42:38 +03:00 committed by GitHub
commit fe0f28c09d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -824,9 +824,10 @@ rec {
or
nix-prefetch-url --type ${hashAlgo} file:///path/to/${name_}
'';
hashAlgo = if hash != null then ""
hashAlgo = if hash != null then (builtins.head (lib.strings.splitString "-" hash))
else if sha256 != null then "sha256"
else "sha1";
hashAlgo_ = if hash != null then "" else hashAlgo;
hash_ = if hash != null then hash
else if sha256 != null then sha256
else sha1;
@ -835,7 +836,7 @@ rec {
stdenvNoCC.mkDerivation {
name = name_;
outputHashMode = hashMode;
outputHashAlgo = hashAlgo;
outputHashAlgo = hashAlgo_;
outputHash = hash_;
preferLocalBuild = true;
allowSubstitutes = false;