2024-01-25 14:12:00 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, coreutils, ocaml-ng, zlib, pcre, pcre2, neko, mbedtls_2, Security }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
2021-03-20 04:20:00 +00:00
|
|
|
ocamlDependencies = version:
|
2024-05-15 15:35:15 +00:00
|
|
|
if lib.versionAtLeast version "4.3"
|
|
|
|
then with ocaml-ng.ocamlPackages_4_14; [
|
2021-03-20 04:20:00 +00:00
|
|
|
ocaml
|
|
|
|
findlib
|
2022-06-16 17:23:12 +00:00
|
|
|
sedlex
|
2021-03-20 04:20:00 +00:00
|
|
|
xml-light
|
|
|
|
ptmap
|
|
|
|
camlp5
|
|
|
|
sha
|
2022-12-17 10:02:37 +00:00
|
|
|
dune_3
|
2021-03-20 04:20:00 +00:00
|
|
|
luv
|
2022-11-21 17:40:18 +00:00
|
|
|
extlib
|
2023-03-24 00:07:29 +00:00
|
|
|
] else with ocaml-ng.ocamlPackages_4_10; [
|
2021-05-03 20:48:10 +00:00
|
|
|
ocaml
|
|
|
|
findlib
|
2022-06-16 17:23:12 +00:00
|
|
|
sedlex
|
2021-05-03 20:48:10 +00:00
|
|
|
xml-light
|
|
|
|
ptmap
|
|
|
|
camlp5
|
|
|
|
sha
|
2022-12-17 10:02:37 +00:00
|
|
|
dune_3
|
2021-05-03 20:48:10 +00:00
|
|
|
luv
|
2022-11-21 17:40:18 +00:00
|
|
|
extlib-1-7-7
|
2021-03-20 04:20:00 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
defaultPatch = ''
|
|
|
|
substituteInPlace extra/haxelib_src/src/haxelib/client/Main.hx \
|
|
|
|
--replace '"neko"' '"${neko}/bin/neko"'
|
|
|
|
'';
|
|
|
|
|
|
|
|
generic = { sha256, version, prePatch ? defaultPatch }:
|
2020-04-24 23:36:52 +00:00
|
|
|
stdenv.mkDerivation {
|
|
|
|
pname = "haxe";
|
|
|
|
inherit version;
|
|
|
|
|
2024-01-25 14:12:00 +00:00
|
|
|
buildInputs = [ zlib neko ]
|
|
|
|
++ (if lib.versionAtLeast version "4.3" then [pcre2] else [pcre])
|
2022-12-17 10:02:37 +00:00
|
|
|
++ lib.optional (lib.versionAtLeast version "4.1") mbedtls_2
|
2021-04-22 02:08:21 +00:00
|
|
|
++ lib.optional (lib.versionAtLeast version "4.1" && stdenv.isDarwin) Security
|
2021-03-20 04:20:00 +00:00
|
|
|
++ ocamlDependencies version;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-03-20 04:20:00 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "HaxeFoundation";
|
|
|
|
repo = "haxe";
|
|
|
|
rev = version;
|
2020-04-24 23:36:52 +00:00
|
|
|
fetchSubmodules = true;
|
2021-03-20 04:20:00 +00:00
|
|
|
inherit sha256;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
inherit prePatch;
|
|
|
|
|
|
|
|
buildFlags = [ "all" "tools" ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
install -vd "$out/bin" "$out/lib/haxe/std"
|
|
|
|
cp -vr haxe haxelib std "$out/lib/haxe"
|
|
|
|
|
|
|
|
# make wrappers which provide a temporary HAXELIB_PATH with symlinks to multiple repositories HAXELIB_PATH may point to
|
|
|
|
for name in haxe haxelib; do
|
|
|
|
cat > $out/bin/$name <<EOF
|
|
|
|
#!{bash}/bin/bash
|
|
|
|
|
|
|
|
if [[ "\$HAXELIB_PATH" =~ : ]]; then
|
|
|
|
NEW_HAXELIB_PATH="\$(${coreutils}/bin/mktemp -d)"
|
|
|
|
|
|
|
|
IFS=':' read -ra libs <<< "\$HAXELIB_PATH"
|
|
|
|
for libdir in "\''${libs[@]}"; do
|
|
|
|
for lib in "\$libdir"/*; do
|
|
|
|
if [ ! -e "\$NEW_HAXELIB_PATH/\$(${coreutils}/bin/basename "\$lib")" ]; then
|
|
|
|
${coreutils}/bin/ln -s "--target-directory=\$NEW_HAXELIB_PATH" "\$lib"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
export HAXELIB_PATH="\$NEW_HAXELIB_PATH"
|
|
|
|
$out/lib/haxe/$name "\$@"
|
|
|
|
rm -rf "\$NEW_HAXELIB_PATH"
|
|
|
|
else
|
|
|
|
exec $out/lib/haxe/$name "\$@"
|
|
|
|
fi
|
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/$name
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
|
|
|
|
# While it might be a good idea to run the upstream test suite, let's at
|
|
|
|
# least make sure we can actually run the compiler.
|
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
# Get out of the source directory to make sure the stdlib from the
|
|
|
|
# sources doesn't interfere with the installed one.
|
|
|
|
mkdir installcheck
|
|
|
|
pushd installcheck > /dev/null
|
|
|
|
cat >> InstallCheck.hx <<EOF
|
|
|
|
class InstallCheck {
|
|
|
|
public static function main() trace("test");
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
"$out/bin/haxe" -js installcheck.js -main InstallCheck
|
|
|
|
grep -q 'console\.log.*test' installcheck.js
|
|
|
|
popd > /dev/null
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Programming language targeting JavaScript, Flash, NekoVM, PHP, C++";
|
|
|
|
homepage = "https://haxe.org";
|
2021-03-20 04:20:00 +00:00
|
|
|
license = with licenses; [ gpl2Plus mit ]; # based on upstream opam file
|
2022-08-12 12:06:08 +00:00
|
|
|
maintainers = [ maintainers.marcweber maintainers.locallycompact maintainers.logo ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in {
|
2021-04-22 02:08:21 +00:00
|
|
|
haxe_4_0 = generic {
|
|
|
|
version = "4.0.5";
|
|
|
|
sha256 = "0f534pchdx0m057ixnk07ab4s518ica958pvpd0vfjsrxg5yjkqa";
|
|
|
|
};
|
|
|
|
haxe_4_1 = generic {
|
|
|
|
version = "4.1.5";
|
|
|
|
sha256 = "0rns6d28qzkbai6yyws08yzbyvxfn848nj0fsji7chdi0y7pzzj0";
|
|
|
|
};
|
2024-01-25 14:12:00 +00:00
|
|
|
haxe_4_3 = generic {
|
2024-05-15 15:35:15 +00:00
|
|
|
version = "4.3.4";
|
|
|
|
sha256 = "sha256-XGV4VG8nUofHGjHbtrLA+2kIpnnPqw5IlcNrP3EsL+Q=";
|
2021-03-20 04:20:00 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|