about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/interpreters/dzaima-apl/default.nix
blob: d061a6cb9cdf5697fe90d616351153d6c6ab2afb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{ lib
, stdenv
, fetchFromGitHub
, jdk
, makeWrapper
, buildNativeImage ? true
}:

stdenv.mkDerivation rec {
  pname = "dapl" + lib.optionalString buildNativeImage "-native";
  version = "0.2.0+date=2021-10-16";

  src = fetchFromGitHub {
    owner = "dzaima";
    repo = "APL";
    rev = "5eb0a4205e27afa6122096a25008474eec562dc0";
    hash = "sha256-UdumMytqT909JRpNqzhYPuKPw644m/vRUsEbIVF2a7U=";
  };

  nativeBuildInputs = [
    jdk
    makeWrapper
  ];

  dontConfigure = true;

  postPatch = ''
    patchShebangs --build ./build
  '';

  buildPhase = ''
    runHook preBuild

    ./build
  '' + lib.optionalString buildNativeImage ''
    native-image --report-unsupported-elements-at-runtime \
      -H:CLibraryPath=${lib.getLib jdk}/lib -J-Dfile.encoding=UTF-8 \
      -jar APL.jar dapl
  '' + ''
    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
  '' + (if buildNativeImage then ''
    mv dapl $out/bin
  '' else ''
    mkdir -p $out/share/${pname}
    mv APL.jar $out/share/${pname}/

    makeWrapper "${lib.getBin jdk}/bin/java" "$out/bin/dapl" \
      --add-flags "-jar $out/share/${pname}/APL.jar"
  '') + ''
    ln -s $out/bin/dapl $out/bin/apl

    runHook postInstall
  '';

  meta = with lib; {
    homepage = "https://github.com/dzaima/APL";
    description = "An APL implementation in Java" + lib.optionalString buildNativeImage ", compiled as a native image";
    license = licenses.mit;
    maintainers = with maintainers; [ AndersonTorres ];
    inherit (jdk.meta) platforms;
  };
}
# TODO: Processing app
# TODO: minimalistic JDK