about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/interpreters/j/default.nix
blob: 97a8064cc60dd66b08588acb57b516d8fb51957a (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{ lib
, stdenv
, fetchFromGitHub
, which
, gmp
, avx2Support ? stdenv.hostPlatform.avx2Support
}:

stdenv.mkDerivation rec {
  pname = "j";
  version = "9.5.1";

  src = fetchFromGitHub {
    owner = "jsoftware";
    repo = "jsource";
    rev = "${version}";
    hash = "sha256-QRQhE8138+zaGQOdq9xUOrifkVIprzbJWbmMK+WhEOU=";
  };

  nativeBuildInputs = [ which ];
  buildInputs = [ gmp ];

  patches = [
    ./fix-install-path.patch
  ];

  enableParallelBuilding = true;

  dontConfigure = true;

  # Emulate jplatform64.sh configuration variables
  jplatform =
    if stdenv.isDarwin then "darwin"
    else if stdenv.hostPlatform.isAarch then "raspberry"
    else if stdenv.isLinux then "linux"
    else "unsupported";

  j64x =
    if stdenv.is32bit then "j32"
    else if stdenv.isx86_64 then
      if stdenv.isLinux && avx2Support then "j64avx2" else "j64"
    else if stdenv.isAarch64 then
      if stdenv.isDarwin then "j64arm" else "j64"
    else "unsupported";

  env.NIX_LDFLAGS = "-lgmp";

  buildPhase = ''
    runHook preBuild
    MAKEFLAGS+=" ''${enableParallelBuilding:+-j$NIX_BUILD_CORES}" \
      jplatform=${jplatform} j64x=${j64x} make2/build_all.sh
    cp -v bin/${jplatform}/${j64x}/* jlibrary/bin/
    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall
    mkdir -p $out/share/j
    cp -r jlibrary/{addons,system} $out/share/j/
    cp -r jlibrary/bin $out/
    runHook postInstall
  '';

  doInstallCheck = false; # The "gregex" test fails due to not finding PCRE2

  installCheckPhase = ''
    runHook preInstallCheck
    HOME="$TMPDIR" $out/bin/jconsole -lib $out/bin/libj* script/testga.ijs
    runHook postInstallCheck
  '';

  meta = with lib; {
    homepage = "https://jsoftware.com/";
    description = "J programming language, an ASCII-based APL successor";
    longDescription = ''
      J is a high-level, general-purpose programming language that is
      particularly suited to the mathematical, statistical, and logical analysis
      of data. It is a powerful tool for developing algorithms and exploring
      problems that are not already well understood.
    '';
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ raskin synthetica AndersonTorres ];
    broken = stdenv.isDarwin;
    platforms = platforms.all;
    mainProgram = "jconsole";
  };
}