about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/text/chroma/default.nix
blob: 390793ffaf1c241e08d747a003738570c8fd8119 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{ lib, buildGoModule, fetchFromGitHub, git }:

buildGoModule rec {
  pname = "chroma";
  version = "0.8.2";

  src = fetchFromGitHub {
    owner  = "alecthomas";
    repo   = pname;
    rev    = "v${version}";
    sha256 = "0vzxd0jvjaakwjvkkkjppakjb00z44k7gb5ng1i4924agh24n5ka";
    leaveDotGit = true;
    fetchSubmodules = true;
  };

  nativeBuildInputs = [ git ];

  # 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 cmd/chroma/main.go \
      --replace 'version = "?"' 'version = "${version}"' \
      --replace 'commit  = "?"' "commit = \"$commit\"" \
      --replace 'date    = "?"' "date = \"$date\""
  '';

  vendorSha256 = "16cnc4scgkx8jan81ymha2q1kidm6hzsnip5mmgbxpqcc2h7hv9m";

  subPackages = [ "cmd/chroma" ];

  meta = with lib; {
    homepage = "https://github.com/alecthomas/chroma";
    description = "A general purpose syntax highlighter in pure Go";
    license = licenses.mit;
    maintainers = [ maintainers.sternenseemann ];
  };
}