1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 jdk,
6 makeWrapper,
7 buildNativeImage ? true,
8}:
9
10stdenv.mkDerivation rec {
11 pname = "dapl" + lib.optionalString buildNativeImage "-native";
12 version = "0.2.0+date=2021-10-16";
13
14 src = fetchFromGitHub {
15 owner = "dzaima";
16 repo = "APL";
17 rev = "5eb0a4205e27afa6122096a25008474eec562dc0";
18 hash = "sha256-UdumMytqT909JRpNqzhYPuKPw644m/vRUsEbIVF2a7U=";
19 };
20
21 nativeBuildInputs = [
22 jdk
23 makeWrapper
24 ];
25
26 dontConfigure = true;
27
28 postPatch = ''
29 patchShebangs --build ./build
30 '';
31
32 buildPhase = ''
33 runHook preBuild
34
35 ./build
36 ''
37 + lib.optionalString buildNativeImage ''
38 native-image --report-unsupported-elements-at-runtime \
39 -H:CLibraryPath=${lib.getLib jdk}/lib -J-Dfile.encoding=UTF-8 \
40 -jar APL.jar dapl
41 ''
42 + ''
43 runHook postBuild
44 '';
45
46 installPhase = ''
47 runHook preInstall
48
49 mkdir -p $out/bin
50 ''
51 + (
52 if buildNativeImage then
53 ''
54 mv dapl $out/bin
55 ''
56 else
57 ''
58 mkdir -p $out/share/${pname}
59 mv APL.jar $out/share/${pname}/
60
61 makeWrapper "${lib.getBin jdk}/bin/java" "$out/bin/dapl" \
62 --add-flags "-jar $out/share/${pname}/APL.jar"
63 ''
64 )
65 + ''
66 ln -s $out/bin/dapl $out/bin/apl
67
68 runHook postInstall
69 '';
70
71 meta = with lib; {
72 homepage = "https://github.com/dzaima/APL";
73 description =
74 "APL implementation in Java" + lib.optionalString buildNativeImage ", compiled as a native image";
75 license = licenses.mit;
76 maintainers = with maintainers; [ ];
77 inherit (jdk.meta) platforms;
78 broken = stdenv.hostPlatform.isDarwin; # never built on Hydra https://hydra.nixos.org/job/nixpkgs/staging-next/dapl-native.x86_64-darwin
79 };
80}
81# TODO: Processing app
82# TODO: minimalistic JDK