diff options
author | sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> | 2021-06-27 11:46:52 +0200 |
---|---|---|
committer | sterni <sternenseemann@systemli.org> | 2021-06-30 12:34:34 +0200 |
commit | b5460f9ce2410a731efa8bb9311691b6fe651239 (patch) | |
tree | 580476e1fb39e37ef07ea2804bc4e4aac7d38222 /pkgs/tools | |
parent | 801a040deef858799cfcab1c2da52e6a76bb1667 (diff) |
chroma: do version info substitution in postFetch
This should increase reproducibility of the derivation as we can delete the .git directory in the src derivation.
Diffstat (limited to 'pkgs/tools')
-rw-r--r-- | pkgs/tools/text/chroma/default.nix | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/pkgs/tools/text/chroma/default.nix b/pkgs/tools/text/chroma/default.nix index 0235e48b298a3..1b9cbcd3727a9 100644 --- a/pkgs/tools/text/chroma/default.nix +++ b/pkgs/tools/text/chroma/default.nix @@ -1,4 +1,4 @@ -{ lib, buildGoModule, fetchFromGitHub, git }: +{ lib, buildGoModule, fetchFromGitHub }: buildGoModule rec { pname = "chroma"; @@ -8,23 +8,26 @@ buildGoModule rec { owner = "alecthomas"; repo = pname; rev = "v${version}"; - sha256 = "0g5l961sr05p0kfj56qcxs9f4x3ji3p6n96zrc16cij5ncncasxw"; + sha256 = "19d7yr6q8kwrm91yyglmw9n7wa861sgi6dbwn8sl6dp55czfwvaq"; + # populate values otherwise taken care of by goreleaser, + # unfortunately these require us to use git. By doing + # this in postFetch we can delete .git afterwards and + # maintain better reproducibility of the src. leaveDotGit = true; - }; + postFetch = '' + cd "$out" - nativeBuildInputs = [ git ]; + commit="$(git rev-parse HEAD)" + date=$(git show -s --format=%aI "$commit") - # populate values otherwise taken care of by goreleaser - # https://github.com/alecthomas/chroma/issues/435 - postPatch = '' - commit="$(git rev-parse HEAD)" - date=$(git show -s --format=%aI "$commit") + substituteInPlace "$out/cmd/chroma/main.go" \ + --replace 'version = "?"' 'version = "${version}"' \ + --replace 'commit = "?"' "commit = \"$commit\"" \ + --replace 'date = "?"' "date = \"$date\"" - substituteInPlace cmd/chroma/main.go \ - --replace 'version = "?"' 'version = "${version}"' \ - --replace 'commit = "?"' "commit = \"$commit\"" \ - --replace 'date = "?"' "date = \"$date\"" - ''; + find "$out" -name .git -print0 | xargs -0 rm -rf + ''; + }; vendorSha256 = "0y8mp08zccn9qxrsj9j7vambz8dwzsxbbgrlppzam53rg8rpxhrg"; |