Commit 1acd69a0 authored by Axel Forsman's avatar Axel Forsman
Browse files
parent ea8bb2df
Loading
Loading
Loading
Loading
+32 −56
Original line number Diff line number Diff line
{ lib
, stdenv
, fetchFromGitHub
, bc
, libedit
, readline
, avxSupport ? stdenv.hostPlatform.avxSupport
, which
, gmp
, avx2Support ? stdenv.hostPlatform.avx2Support
}:

stdenv.mkDerivation rec {
  pname = "j";
  version = "904-beta-c";
  version = "9.5.1";

  src = fetchFromGitHub {
    name = "${pname}-source";
    owner = "jsoftware";
    repo = "jsource";
    rev = "j${version}";
    hash = "sha256-MzEO/saHEBl1JwVlFC6P2UKm9RZnV7KVrNd9h4cPV/w=";
    rev = "${version}";
    hash = "sha256-QRQhE8138+zaGQOdq9xUOrifkVIprzbJWbmMK+WhEOU=";
  };

  buildInputs = [
    readline
    libedit
    bc
  ];
  nativeBuildInputs = [ which ];
  buildInputs = [ gmp ];

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

  enableParallelBuilding = true;

  dontConfigure = true;

  # emulating build_all.sh configuration variables
  # Emulate jplatform64.sh configuration variables
  jplatform =
    if stdenv.isDarwin then "darwin"
    else if stdenv.hostPlatform.isAarch then "raspberry"
@@ -41,62 +38,39 @@ stdenv.mkDerivation rec {
  j64x =
    if stdenv.is32bit then "j32"
    else if stdenv.isx86_64 then
      if (stdenv.isLinux && avxSupport) then "j64avx" else "j64"
      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

    export SRCDIR=$(pwd)
    export HOME=$TMPDIR
    export JLIB=$SRCDIR/jlibrary
    export CC=cc

    cd make2

    patchShebangs .

    j64x="${j64x}" jplatform="${jplatform}" ./build_all.sh

    cp -v $SRCDIR/bin/${jplatform}/${j64x}/* "$JLIB/bin"

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

  doCheck = true;

  checkPhase = ''
    runHook preCheck

    echo "Smoke test"
    echo 'i. 10' | $JLIB/bin/jconsole | fgrep "0 1 2 3 4 5 6 7 8 9"

    # Now run the real tests
    pushd $SRCDIR/test
    for f in *.ijs
    do
      echo -n "test $f: "
      $JLIB/bin/jconsole < $f > /dev/null || echo FAIL && echo PASS
    done
    popd

    runHook postCheck
  '';

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

    mkdir -p "$out/share/j/"
    cp -r $JLIB/{addons,system} "$out/share/j"
    cp -r $JLIB/bin "$out"
  doInstallCheck = false; # The "gregex" test fails due to not finding PCRE2

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

  meta = with lib; {
    homepage = "http://jsoftware.com/";
    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
@@ -104,8 +78,10 @@ stdenv.mkDerivation rec {
      of data. It is a powerful tool for developing algorithms and exploring
      problems that are not already well understood.
    '';
    license = licenses.gpl3Plus;
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ raskin synthetica AndersonTorres ];
    platforms = with platforms; unix;
    broken = stdenv.isDarwin;
    platforms = platforms.all;
    mainProgram = "jconsole";
  };
}
+1 −3
Original line number Diff line number Diff line
@@ -17680,9 +17680,7 @@ with pkgs;
  ivy = callPackage ../development/interpreters/ivy { };
  j = callPackage ../development/interpreters/j {
    stdenv = clangStdenv;
  };
  j = callPackage ../development/interpreters/j { };
  jacinda = haskell.lib.compose.justStaticExecutables haskellPackages.jacinda;