about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/jj/jj/package.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2024-01-06 02:12:23 +0100
committerAlyssa Ross <hi@alyssa.is>2024-01-06 02:12:23 +0100
commitf34a1b70eb86e4a63cfb88ea460345bb1aed88e3 (patch)
tree32834d23912250e0c4b86aa4420baacf8091c0fe /nixpkgs/pkgs/by-name/jj/jj/package.nix
parent003ab91dd67b093890db1dd0bab564345db6e496 (diff)
parent7a7cfff8915e06365bc2365ff33d4d413184fa9f (diff)
downloadnixlib-f34a1b70eb86e4a63cfb88ea460345bb1aed88e3.tar
nixlib-f34a1b70eb86e4a63cfb88ea460345bb1aed88e3.tar.gz
nixlib-f34a1b70eb86e4a63cfb88ea460345bb1aed88e3.tar.bz2
nixlib-f34a1b70eb86e4a63cfb88ea460345bb1aed88e3.tar.lz
nixlib-f34a1b70eb86e4a63cfb88ea460345bb1aed88e3.tar.xz
nixlib-f34a1b70eb86e4a63cfb88ea460345bb1aed88e3.tar.zst
nixlib-f34a1b70eb86e4a63cfb88ea460345bb1aed88e3.zip
Merge branch 'nixos-unstable-small' of https://github.com/NixOS/nixpkgs
Conflicts:
	nixpkgs/pkgs/build-support/go/module.nix
Diffstat (limited to 'nixpkgs/pkgs/by-name/jj/jj/package.nix')
-rw-r--r--nixpkgs/pkgs/by-name/jj/jj/package.nix73
1 files changed, 73 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/by-name/jj/jj/package.nix b/nixpkgs/pkgs/by-name/jj/jj/package.nix
new file mode 100644
index 000000000000..c94bb6d2e7e4
--- /dev/null
+++ b/nixpkgs/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 ];
+  };
+}