From 8bd0cd850b9808734589065f4f720ea202e5bddf Mon Sep 17 00:00:00 2001 From: K900 Date: Fri, 4 Aug 2023 15:34:30 +0300 Subject: [PATCH] requireFile: fix error message with SRI hashes --- pkgs/build-support/trivial-builders/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/trivial-builders/default.nix b/pkgs/build-support/trivial-builders/default.nix index d095974513cb..dcdac09004bb 100644 --- a/pkgs/build-support/trivial-builders/default.nix +++ b/pkgs/build-support/trivial-builders/default.nix @@ -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;