diff --git a/pkgs/tools/text/chroma/default.nix b/pkgs/tools/text/chroma/default.nix index 206a9e35e4d1..f99c090eb975 100644 --- a/pkgs/tools/text/chroma/default.nix +++ b/pkgs/tools/text/chroma/default.nix @@ -1,38 +1,32 @@ { lib, buildGoModule, fetchFromGitHub }: +let + srcInfo = builtins.fromJSON (builtins.readFile ./src.json); +in + buildGoModule rec { pname = "chroma"; version = "0.9.4"; + # To update: + # nix-prefetch-git --rev v${version} https://github.com/alecthomas/chroma.git > src.json src = fetchFromGitHub { owner = "alecthomas"; repo = pname; rev = "v${version}"; - sha256 = "14jp6f83ca2srcylf9w6v7cvznrm1sbpcs6lk7pimgr3jhy5j339"; - # 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" - - 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\"" - - find "$out" -name .git -print0 | xargs -0 rm -rf - ''; + inherit (srcInfo) sha256; }; vendorSha256 = "1l5ryhwifhff41r4z1d2lifpvjcc4yi1vzrzlvkx3iy9dmxqcssl"; modRoot = "./cmd/chroma"; + # substitute version info as done in goreleaser builds + ldflags = [ + "-X" "main.version=${version}" + "-X" "main.commit=${srcInfo.rev}" + "-X" "main.date=${srcInfo.date}" + ]; meta = with lib; { homepage = "https://github.com/alecthomas/chroma"; diff --git a/pkgs/tools/text/chroma/src.json b/pkgs/tools/text/chroma/src.json new file mode 100644 index 000000000000..9bfc8d9c2c73 --- /dev/null +++ b/pkgs/tools/text/chroma/src.json @@ -0,0 +1,11 @@ +{ + "url": "https://github.com/alecthomas/chroma.git", + "rev": "6520148857c2ae3106ff371e527abea815b23915", + "date": "2021-10-17T08:46:20+11:00", + "path": "/nix/store/0s8a46d1nyjl3yhsgni2jz5vdv95cka8-chroma", + "sha256": "1iy6mymdjxbl5wbll1mivv7gqdyqhl6xpfqps99z307m7y38r1ni", + "fetchLFS": false, + "fetchSubmodules": false, + "deepClone": false, + "leaveDotGit": false +}