nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 168 lines 4.2 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 coreutils, 6 ocaml-ng, 7 dune, 8 zlib, 9 pcre, 10 pcre2, 11 neko, 12 mbedtls_2, 13}: 14let 15 ocamlDependencies = 16 version: 17 if lib.versionAtLeast version "4.3" then 18 with ocaml-ng.ocamlPackages_4_14; 19 [ 20 ocaml 21 findlib 22 sedlex 23 xml-light 24 ptmap 25 camlp5 26 sha 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 luv 41 extlib-1-7-7 42 ]; 43 44 defaultPatch = '' 45 substituteInPlace extra/haxelib_src/src/haxelib/client/Main.hx \ 46 --replace '"neko"' '"${neko}/bin/neko"' 47 ''; 48 49 generic = 50 { 51 hash, 52 version, 53 prePatch ? defaultPatch, 54 patches ? [ ], 55 }: 56 stdenv.mkDerivation { 57 pname = "haxe"; 58 inherit version; 59 60 buildInputs = [ 61 zlib 62 neko 63 dune 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 = { 138 description = "Programming language targeting JavaScript, Flash, NekoVM, PHP, C++"; 139 homepage = "https://haxe.org"; 140 license = with lib.licenses; [ 141 gpl2Plus 142 mit 143 ]; # based on upstream opam file 144 maintainers = [ 145 lib.maintainers.marcweber 146 lib.maintainers.locallycompact 147 lib.maintainers.logo 148 lib.maintainers.bwkam 149 ]; 150 platforms = lib.platforms.linux ++ lib.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}