Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 23.05 131 lines 3.9 kB view raw
1{ lib, stdenv, fetchFromGitHub, coreutils, ocaml-ng, zlib, pcre, neko, mbedtls_2, Security }: 2 3let 4 ocamlDependencies = version: 5 if lib.versionAtLeast version "4.2" 6 then with ocaml-ng.ocamlPackages_4_12; [ 7 ocaml 8 findlib 9 sedlex 10 xml-light 11 ptmap 12 camlp5 13 sha 14 dune_3 15 luv 16 extlib 17 ] else with ocaml-ng.ocamlPackages_4_10; [ 18 ocaml 19 findlib 20 sedlex 21 xml-light 22 ptmap 23 camlp5 24 sha 25 dune_3 26 luv 27 extlib-1-7-7 28 ]; 29 30 defaultPatch = '' 31 substituteInPlace extra/haxelib_src/src/haxelib/client/Main.hx \ 32 --replace '"neko"' '"${neko}/bin/neko"' 33 ''; 34 35 generic = { sha256, version, prePatch ? defaultPatch }: 36 stdenv.mkDerivation { 37 pname = "haxe"; 38 inherit version; 39 40 buildInputs = [ zlib pcre neko ] 41 ++ lib.optional (lib.versionAtLeast version "4.1") mbedtls_2 42 ++ lib.optional (lib.versionAtLeast version "4.1" && stdenv.isDarwin) Security 43 ++ ocamlDependencies version; 44 45 src = fetchFromGitHub { 46 owner = "HaxeFoundation"; 47 repo = "haxe"; 48 rev = version; 49 fetchSubmodules = true; 50 inherit sha256; 51 }; 52 53 inherit prePatch; 54 55 buildFlags = [ "all" "tools" ]; 56 57 installPhase = '' 58 install -vd "$out/bin" "$out/lib/haxe/std" 59 cp -vr haxe haxelib std "$out/lib/haxe" 60 61 # make wrappers which provide a temporary HAXELIB_PATH with symlinks to multiple repositories HAXELIB_PATH may point to 62 for name in haxe haxelib; do 63 cat > $out/bin/$name <<EOF 64 #!{bash}/bin/bash 65 66 if [[ "\$HAXELIB_PATH" =~ : ]]; then 67 NEW_HAXELIB_PATH="\$(${coreutils}/bin/mktemp -d)" 68 69 IFS=':' read -ra libs <<< "\$HAXELIB_PATH" 70 for libdir in "\''${libs[@]}"; do 71 for lib in "\$libdir"/*; do 72 if [ ! -e "\$NEW_HAXELIB_PATH/\$(${coreutils}/bin/basename "\$lib")" ]; then 73 ${coreutils}/bin/ln -s "--target-directory=\$NEW_HAXELIB_PATH" "\$lib" 74 fi 75 done 76 done 77 export HAXELIB_PATH="\$NEW_HAXELIB_PATH" 78 $out/lib/haxe/$name "\$@" 79 rm -rf "\$NEW_HAXELIB_PATH" 80 else 81 exec $out/lib/haxe/$name "\$@" 82 fi 83 EOF 84 chmod +x $out/bin/$name 85 done 86 ''; 87 88 setupHook = ./setup-hook.sh; 89 90 dontStrip = true; 91 92 # While it might be a good idea to run the upstream test suite, let's at 93 # least make sure we can actually run the compiler. 94 doInstallCheck = true; 95 installCheckPhase = '' 96 # Get out of the source directory to make sure the stdlib from the 97 # sources doesn't interfere with the installed one. 98 mkdir installcheck 99 pushd installcheck > /dev/null 100 cat >> InstallCheck.hx <<EOF 101 class InstallCheck { 102 public static function main() trace("test"); 103 } 104 EOF 105 "$out/bin/haxe" -js installcheck.js -main InstallCheck 106 grep -q 'console\.log.*test' installcheck.js 107 popd > /dev/null 108 ''; 109 110 meta = with lib; { 111 description = "Programming language targeting JavaScript, Flash, NekoVM, PHP, C++"; 112 homepage = "https://haxe.org"; 113 license = with licenses; [ gpl2Plus mit ]; # based on upstream opam file 114 maintainers = [ maintainers.marcweber maintainers.locallycompact maintainers.logo ]; 115 platforms = platforms.linux ++ platforms.darwin; 116 }; 117 }; 118in { 119 haxe_4_0 = generic { 120 version = "4.0.5"; 121 sha256 = "0f534pchdx0m057ixnk07ab4s518ica958pvpd0vfjsrxg5yjkqa"; 122 }; 123 haxe_4_1 = generic { 124 version = "4.1.5"; 125 sha256 = "0rns6d28qzkbai6yyws08yzbyvxfn848nj0fsji7chdi0y7pzzj0"; 126 }; 127 haxe_4_2 = generic { 128 version = "4.2.5"; 129 sha256 = "sha256-Y0gx6uOQX4OZgg8nK4GJxRR1rKh0S2JUjZQFVQ4cfTs="; 130 }; 131}