forked from mirrors/nixpkgs
2174bfe675
Previously this was done rather hackily using substituteInPlace in postFetch, however I've since found out that the way goreleaser does it is actually quite accessible, since it just calls go with the appropriate -X flags. To avoid having to call git in the build to obtain the values and to not rely on leaveDotGit, we can use the JSON populated by nix-prefetch-git which contains the extra information we need: the commit hash and the date.
38 lines
937 B
Nix
38 lines
937 B
Nix
{ 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}";
|
|
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";
|
|
description = "A general purpose syntax highlighter in pure Go";
|
|
license = licenses.mit;
|
|
maintainers = [ maintainers.sternenseemann ];
|
|
};
|
|
}
|