From c034d14c4163964be3f35003cad46e0fb4aa8ae6 Mon Sep 17 00:00:00 2001 From: Francesco Gazzetta Date: Wed, 22 Nov 2023 09:47:57 +0100 Subject: [PATCH] fetchfossil: support SRI hashes --- pkgs/build-support/fetchfossil/default.nix | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/fetchfossil/default.nix b/pkgs/build-support/fetchfossil/default.nix index 7866c403ec42..3f3bf69db047 100644 --- a/pkgs/build-support/fetchfossil/default.nix +++ b/pkgs/build-support/fetchfossil/default.nix @@ -1,7 +1,15 @@ {stdenv, lib, fossil, cacert}: -{name ? null, url, rev, sha256}: +{ name ? null +, url +, rev +, sha256 ? "" +, hash ? "" +}: +if hash != "" && sha256 != "" then + throw "Only one of sha256 or hash can be set" +else stdenv.mkDerivation { name = "fossil-archive" + (lib.optionalString (name != null) "-${name}"); builder = ./builder.sh; @@ -11,9 +19,14 @@ stdenv.mkDerivation { # https://www.fossil-scm.org/index.html/doc/trunk/www/env-opts.md impureEnvVars = [ "http_proxy" ]; - outputHashAlgo = "sha256"; + outputHashAlgo = if hash != "" then null else "sha256"; outputHashMode = "recursive"; - outputHash = sha256; + outputHash = if hash != "" then + hash + else if sha256 != "" then + sha256 + else + lib.fakeSha256; inherit url rev; preferLocalBuild = true;