7 , onigurumaSupport ? true
11 stdenv.mkDerivation rec {
15 # Note: do not use fetchpatch or fetchFromGitHub to keep this package available in __bootPackages
17 url = "https://github.com/jqlang/jq/releases/download/jq-${version}/jq-${version}.tar.gz";
18 hash = "sha256-R4ycoSn9LjRD/icxS0VeIR4NjGC8j/ffcDhz3u7lgMI=";
21 outputs = [ "bin" "doc" "man" "dev" "lib" "out" ];
23 # Upstream script that writes the version that's eventually compiled
24 # and printed in `jq --help` relies on a .git directory which our src
27 echo "#!/bin/sh" > scripts/version
28 echo "echo ${version}" >> scripts/version
29 patchShebangs scripts/version
32 # paranoid mode: make sure we never use vendored version of oniguruma
33 # Note: it must be run after automake, or automake will complain
35 rm -r ./modules/oniguruma
38 buildInputs = lib.optionals onigurumaSupport [ oniguruma ];
39 nativeBuildInputs = [ removeReferencesTo autoreconfHook bison ];
41 # Darwin requires _REENTRANT be defined to use functions like `lgamma_r`.
42 # Otherwise, configure will detect that they’re in libm, but the build will fail
43 # with clang 16+ due to calls to undeclared functions.
44 # This is fixed upstream and can be removed once jq is updated (to 1.7 or an unstable release).
45 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin (toString [
47 "-D_DARWIN_C_SOURCE=1"
51 "--bindir=\${bin}/bin"
52 "--sbindir=\${bin}/bin"
53 "--datadir=\${doc}/share"
54 "--mandir=\${man}/share/man"
55 ] ++ lib.optional (!onigurumaSupport) "--with-oniguruma=no"
56 # jq is linked to libjq:
57 ++ lib.optional (!stdenv.isDarwin) "LDFLAGS=-Wl,-rpath,\\\${libdir}";
59 # Break the dependency cycle: $dev refers to $bin via propagated-build-outputs, and
60 # $bin refers to $dev because of https://github.com/jqlang/jq/commit/583e4a27188a2db097dd043dd203b9c106bba100
62 remove-references-to -t "$dev" "$bin/bin/jq"
65 doInstallCheck = true;
66 installCheckTarget = "check";
69 $bin/bin/jq --help >/dev/null
70 $bin/bin/jq -r '.values[1]' <<< '{"values":["hello","world"]}' | grep '^world$' > /dev/null
73 passthru = { inherit onigurumaSupport; };
76 description = "A lightweight and flexible command-line JSON processor";
77 homepage = "https://jqlang.github.io/jq/";
78 license = licenses.mit;
79 maintainers = with maintainers; [ raskin artturin ncfavier ];
80 platforms = platforms.unix;
81 downloadPage = "https://jqlang.github.io/jq/download/";