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