Skip to content

Commit

Permalink
fetchgit: support hash parameter alongside sha256
Browse files Browse the repository at this point in the history
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
  • Loading branch information
mkg20001 and SuperSandro2000 committed Nov 9, 2021
1 parent c11d08f commit 5c2b1b6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkgs/build-support/fetchgit/default.nix
Expand Up @@ -12,7 +12,7 @@
else "";
in "${if matched == null then base else builtins.head matched}${appendShort}";
in
{ url, rev ? "HEAD", md5 ? "", sha256 ? "", leaveDotGit ? deepClone
{ url, rev ? "HEAD", md5 ? "", sha256 ? "", hash ? "", leaveDotGit ? deepClone
, fetchSubmodules ? true, deepClone ? false
, branchName ? null
, name ? urlToName url rev
Expand Down Expand Up @@ -54,6 +54,8 @@ assert deepClone -> leaveDotGit;

if md5 != "" then
throw "fetchgit does not support md5 anymore, please use sha256"
else if hash != "" && sha256 != "" then
throw "Only one of sha256 or hash can be set"
else
stdenvNoCC.mkDerivation {
inherit name;
Expand All @@ -63,9 +65,14 @@ stdenvNoCC.mkDerivation {
nativeBuildInputs = [ git ]
++ lib.optionals fetchLFS [ git-lfs ];

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 leaveDotGit fetchLFS fetchSubmodules deepClone branchName postFetch;

Expand Down

1 comment on commit 5c2b1b6

@nixos-discourse
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/is-it-ok-to-ask-for-hash-attribute-and-sri-hash-when-reviewing-prs-that-update-packages/20493/4

Please sign in to comment.