Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, stdenv
3, fetchFromGitHub
4, bc
5, libedit
6, readline
7, avxSupport ? stdenv.hostPlatform.avxSupport
8}:
9
10stdenv.mkDerivation rec {
11 pname = "j";
12 version = "904-beta-c";
13
14 src = fetchFromGitHub {
15 name = "${pname}-source";
16 owner = "jsoftware";
17 repo = "jsource";
18 rev = "j${version}";
19 hash = "sha256-MzEO/saHEBl1JwVlFC6P2UKm9RZnV7KVrNd9h4cPV/w=";
20 };
21
22 buildInputs = [
23 readline
24 libedit
25 bc
26 ];
27
28 patches = [
29 ./fix-install-path.patch
30 ];
31
32 dontConfigure = true;
33
34 # emulating build_all.sh configuration variables
35 jplatform =
36 if stdenv.isDarwin then "darwin"
37 else if stdenv.hostPlatform.isAarch then "raspberry"
38 else if stdenv.isLinux then "linux"
39 else "unsupported";
40
41 j64x =
42 if stdenv.is32bit then "j32"
43 else if stdenv.isx86_64 then
44 if (stdenv.isLinux && avxSupport) then "j64avx" else "j64"
45 else if stdenv.isAarch64 then
46 if stdenv.isDarwin then "j64arm" else "j64"
47 else "unsupported";
48
49 buildPhase = ''
50 runHook preBuild
51
52 export SRCDIR=$(pwd)
53 export HOME=$TMPDIR
54 export JLIB=$SRCDIR/jlibrary
55 export CC=cc
56
57 cd make2
58
59 patchShebangs .
60
61 j64x="${j64x}" jplatform="${jplatform}" ./build_all.sh
62
63 cp -v $SRCDIR/bin/${jplatform}/${j64x}/* "$JLIB/bin"
64
65 runHook postBuild
66 '';
67
68 doCheck = true;
69
70 checkPhase = ''
71 runHook preCheck
72
73 echo "Smoke test"
74 echo 'i. 10' | $JLIB/bin/jconsole | fgrep "0 1 2 3 4 5 6 7 8 9"
75
76 # Now run the real tests
77 pushd $SRCDIR/test
78 for f in *.ijs
79 do
80 echo -n "test $f: "
81 $JLIB/bin/jconsole < $f > /dev/null || echo FAIL && echo PASS
82 done
83 popd
84
85 runHook postCheck
86 '';
87
88 installPhase = ''
89 runHook preInstall
90
91 mkdir -p "$out/share/j/"
92 cp -r $JLIB/{addons,system} "$out/share/j"
93 cp -r $JLIB/bin "$out"
94
95 runHook postInstall
96 '';
97
98 meta = with lib; {
99 homepage = "http://jsoftware.com/";
100 description = "J programming language, an ASCII-based APL successor";
101 longDescription = ''
102 J is a high-level, general-purpose programming language that is
103 particularly suited to the mathematical, statistical, and logical analysis
104 of data. It is a powerful tool for developing algorithms and exploring
105 problems that are not already well understood.
106 '';
107 license = licenses.gpl3Plus;
108 maintainers = with maintainers; [ raskin synthetica AndersonTorres ];
109 platforms = with platforms; unix;
110 };
111}