fetchfossil: support SRI hashes

+16 -3
+16 -3
pkgs/build-support/fetchfossil/default.nix
··· 1 {stdenv, lib, fossil, cacert}: 2 3 - {name ? null, url, rev, sha256}: 4 5 stdenv.mkDerivation { 6 name = "fossil-archive" + (lib.optionalString (name != null) "-${name}"); 7 builder = ./builder.sh; ··· 11 # https://www.fossil-scm.org/index.html/doc/trunk/www/env-opts.md 12 impureEnvVars = [ "http_proxy" ]; 13 14 - outputHashAlgo = "sha256"; 15 outputHashMode = "recursive"; 16 - outputHash = sha256; 17 18 inherit url rev; 19 preferLocalBuild = true;
··· 1 {stdenv, lib, fossil, cacert}: 2 3 + { name ? null 4 + , url 5 + , rev 6 + , sha256 ? "" 7 + , hash ? "" 8 + }: 9 10 + if hash != "" && sha256 != "" then 11 + throw "Only one of sha256 or hash can be set" 12 + else 13 stdenv.mkDerivation { 14 name = "fossil-archive" + (lib.optionalString (name != null) "-${name}"); 15 builder = ./builder.sh; ··· 19 # https://www.fossil-scm.org/index.html/doc/trunk/www/env-opts.md 20 impureEnvVars = [ "http_proxy" ]; 21 22 + outputHashAlgo = if hash != "" then null else "sha256"; 23 outputHashMode = "recursive"; 24 + outputHash = if hash != "" then 25 + hash 26 + else if sha256 != "" then 27 + sha256 28 + else 29 + lib.fakeSha256; 30 31 inherit url rev; 32 preferLocalBuild = true;