@@ -0,0 +1,66 @@
1+{ lib
2+, stdenv
3+, fetchFromGitHub
4+, jdk
5+, makeWrapper
6+, buildNativeImage ? true
7+}:
8+
9+stdenv.mkDerivation rec {
10+ pname = "dapl" + lib.optionalString buildNativeImage "-native";
11+ version = "0.2.0+unstable=2021-06-30";
12+
13+ src = fetchFromGitHub {
14+ owner = "dzaima";
15+ repo = "APL";
16+ rev = "28b3667beb23c6472266bb2b6eb701708fa421c6";
17+ hash = "sha256-2kM9XDMclxJNOZngwLvoDQG23UZQQ6ePK/j215UumCg=";
18+ };
19+
20+ nativeBuildInputs = [
21+ makeWrapper
22+ jdk
23+ ];
24+
25+ dontConfigure = true;
26+
27+ buildPhase = ''
28+ runHook preBuild
29+
30+ patchShebangs --build ./build
31+ ./build
32+ '' + lib.optionalString buildNativeImage ''
33+ native-image --report-unsupported-elements-at-runtime \
34+ -H:CLibraryPath=${lib.getLib jdk}/lib -jar APL.jar dapl
35+ '' + ''
36+ runHook postBuild
37+ '';
38+
39+ installPhase = ''
40+ runHook preInstall
41+
42+ mkdir -p $out/bin
43+ '' + (if buildNativeImage then ''
44+ mv dapl $out/bin
45+ '' else ''
46+ mkdir -p $out/share/${pname}
47+ mv APL.jar $out/share/${pname}/
48+
49+ makeWrapper "${lib.getBin jdk}/bin/java" "$out/bin/dapl" \
50+ --add-flags "-jar $out/share/${pname}/APL.jar"
51+ '') + ''
52+ ln -s $out/bin/dapl $out/bin/apl
53+
54+ runHook postInstall
55+ '';
56+
57+ meta = with lib; {
58+ homepage = "https://github.com/dzaima/APL";
59+ description = "An APL implementation in Java" + lib.optionalString buildNativeImage ", compiled as a native image";
60+ license = licenses.mit;
61+ maintainers = with maintainers; [ AndersonTorres ];
62+ inherit (jdk.meta) platforms;
63+ };
64+}
65+# TODO: Processing app
66+# TODO: minimalistic JDK