about summary refs log tree commit diff
path: root/pkgs/by-name/jj
diff options
context:
space:
mode:
authorPaul Meyer <49727155+katexochen@users.noreply.github.com>2023-12-16 16:22:51 +0100
committerPaul Meyer <49727155+katexochen@users.noreply.github.com>2023-12-16 16:22:51 +0100
commit418296e34e61d4f5bd7492d5988b5ab9da0875a5 (patch)
tree00e5aa6384f5aea30c2224ceb11919446752158f /pkgs/by-name/jj
parent655a9cf33ecaff88fbb40cb6d8b7a386ff4baee5 (diff)
jj: init at 1.9.2
Diffstat (limited to 'pkgs/by-name/jj')
-rw-r--r--pkgs/by-name/jj/jj/package.nix73
1 files changed, 73 insertions, 0 deletions
diff --git a/pkgs/by-name/jj/jj/package.nix b/pkgs/by-name/jj/jj/package.nix
new file mode 100644
index 0000000000000..c94bb6d2e7e45
--- /dev/null
+++ b/pkgs/by-name/jj/jj/package.nix
@@ -0,0 +1,73 @@
+{ lib
+, buildGoModule
+, fetchFromGitHub
+, nix-update-script
+, testers
+, writeText
+, runCommand
+, jj
+}:
+buildGoModule rec {
+  pname = "jj";
+  version = "1.9.2";
+
+  src = fetchFromGitHub {
+    owner = "tidwall";
+    repo = "jj";
+    rev = "v${version}";
+    hash = "sha256-Yijap5ZghTBe1ahkQgjjxuo++SriJWXgRqrNXIVQ0os=";
+  };
+
+  vendorHash = "sha256-39rA3jMGYhsh1nrGzI1vfHZzZDy4O6ooYWB8af654mM=";
+
+  subPackages = [ "cmd/jj" ];
+
+  CGO_ENABLED = "0";
+
+  ldflags = [
+    "-s"
+    "-w"
+    "-X main.version=${version}"
+  ];
+
+  passthru = {
+    updateScript = nix-update-script { };
+    tests = with testers; {
+      version = testVersion { package = jj; };
+      examples = testEqualContents {
+        assertion = "examples from projects README.md work";
+        actual = runCommand "actual" { nativeBuildInputs = [ jj ]; } ''
+          {
+            echo '{"name":{"first":"Tom","last":"Smith"}}' | jj name.last
+            echo '{"name":{"first":"Tom","last":"Smith"}}' | jj name
+            echo '{"name":{"first":"Tom","last":"Smith"}}' | jj -v Andy name.first
+            echo '{"friends":["Tom","Jane","Carol"]}' | jj -v Andy friends.-1
+            echo '{"age":46,"name":{"first":"Tom","last":"Smith"}}' | jj -D age
+          } > $out
+        '';
+        expected = writeText "expected" ''
+          Smith
+          {"first":"Tom","last":"Smith"}
+          {"name":{"first":"Andy","last":"Smith"}}
+          {"friends":["Tom","Jane","Carol","Andy"]}
+          {"name":{"first":"Tom","last":"Smith"}}
+        '';
+      };
+    };
+  };
+
+  meta = with lib; {
+    description = "JSON Stream Editor (command line utility)";
+    longDescription = ''
+      JJ is a command line utility that provides a fast and simple way to retrieve
+      or update values from JSON documents. It's powered by GJSON and SJSON under the hood.
+      It's fast because it avoids parsing irrelevant sections of json, skipping over values
+      that do not apply, and aborts as soon as the target value has been found or updated.
+    '';
+    homepage = "https://github.com/tidwall/jj";
+    changelog = "https://github.com/tidwall/jj/releases/tag/v${version}";
+    license = licenses.mit;
+    mainProgram = "jj";
+    maintainers = with maintainers; [ katexochen ];
+  };
+}