about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/text/chroma/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/text/chroma/default.nix')
-rw-r--r--nixpkgs/pkgs/tools/text/chroma/default.nix42
1 files changed, 42 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/tools/text/chroma/default.nix b/nixpkgs/pkgs/tools/text/chroma/default.nix
new file mode 100644
index 000000000000..1b9cbcd3727a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/text/chroma/default.nix
@@ -0,0 +1,42 @@
+{ lib, buildGoModule, fetchFromGitHub }:
+
+buildGoModule rec {
+  pname = "chroma";
+  version = "0.9.2";
+
+  src = fetchFromGitHub {
+    owner  = "alecthomas";
+    repo   = pname;
+    rev    = "v${version}";
+    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"
+
+      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
+    '';
+  };
+
+  vendorSha256 = "0y8mp08zccn9qxrsj9j7vambz8dwzsxbbgrlppzam53rg8rpxhrg";
+
+  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 ];
+  };
+}