@@ -0,0 +1,59 @@
1+{ stdenv, lib, graalvm11-ce, fetchurl }:
2+
3+stdenv.mkDerivation rec {
4+ pname = "jet";
5+ version = "0.1.0";
6+
7+ src = fetchurl {
8+ url = "https://github.com/borkdude/${pname}/releases/download/v${version}/${pname}-${version}-standalone.jar";
9+ sha256 = "sha256-RCEIIZfPmOLW3akjEgaEas4xOtYxL6lQsxDv2szB8K4";
10+ };
11+
12+ reflectionJson = fetchurl {
13+ url = "https://raw.githubusercontent.com/borkdude/${pname}/v${version}/reflection.json";
14+ sha256 = "sha256-mOUiKEM5tYhtpBpm7KtslyPYFsJ+Wr+4ul6Zi4aS09Q=";
15+ };
16+
17+ dontUnpack = true;
18+
19+ buildInputs = [ graalvm11-ce ];
20+
21+ buildPhase = ''
22+ runHook preBuild
23+
24+ # https://github.com/borkdude/jet/blob/v0.1.0/script/compile#L16-L29
25+ args=("-jar" "$src"
26+ "-H:CLibraryPath=${graalvm11-ce.lib}/lib"
27+ # Required to build jet on darwin. Do not remove.
28+ "${lib.optionalString stdenv.isDarwin "-H:-CheckToolchain"}"
29+ "-H:Name=jet"
30+ "-H:+ReportExceptionStackTraces"
31+ "-J-Dclojure.spec.skip-macros=true"
32+ "-J-Dclojure.compiler.direct-linking=true"
33+ "-H:IncludeResources=JET_VERSION"
34+ "-H:ReflectionConfigurationFiles=${reflectionJson}"
35+ "--initialize-at-build-time"
36+ "-H:Log=registerResource:"
37+ "--verbose"
38+ "--no-fallback"
39+ "--no-server"
40+ "-J-Xmx3g")
41+
42+ native-image ''${args[@]}
43+
44+ runHook postBuild
45+ '';
46+
47+ installPhase = ''
48+ mkdir -p $out/bin
49+ cp jet $out/bin/jet
50+ '';
51+
52+ meta = with lib; {
53+ description = "CLI to transform between JSON, EDN and Transit, powered with a minimal query language";
54+ homepage = "https://github.com/borkdude/jet";
55+ license = licenses.epl10;
56+ platforms = graalvm11-ce.meta.platforms;
57+ maintainers = with maintainers; [ ericdallo ];
58+ };
59+}