summary refs log tree commit diff
path: root/pkgs/development/compilers/haxe
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-03-19 15:25:23 +0100
committersterni <sternenseemann@systemli.org>2021-03-25 22:11:00 +0100
commit2fd41fd2031b5d876804cbb38874664ac7eba404 (patch)
tree41b924414e173e3b1971fff9f00646128bb62f3a /pkgs/development/compilers/haxe
parentdc376c7e75eed7ece24a976d3d1e503d3138003c (diff)
downloadnixpkgs-2fd41fd2031b5d876804cbb38874664ac7eba404.tar
nixpkgs-2fd41fd2031b5d876804cbb38874664ac7eba404.tar.gz
nixpkgs-2fd41fd2031b5d876804cbb38874664ac7eba404.tar.bz2
nixpkgs-2fd41fd2031b5d876804cbb38874664ac7eba404.tar.lz
nixpkgs-2fd41fd2031b5d876804cbb38874664ac7eba404.tar.xz
nixpkgs-2fd41fd2031b5d876804cbb38874664ac7eba404.tar.zst
nixpkgs-2fd41fd2031b5d876804cbb38874664ac7eba404.zip
haxe: 3.4.6 -> 4.2.1
haxe_4_2: init at 4.2.1

haxe_3_4, haxe_3_2 still exist.

Co-authored-by: Daniel Firth <dan.firth@homotopic.tech>
Diffstat (limited to 'pkgs/development/compilers/haxe')
-rw-r--r--pkgs/development/compilers/haxe/default.nix53
1 files changed, 41 insertions, 12 deletions
diff --git a/pkgs/development/compilers/haxe/default.nix b/pkgs/development/compilers/haxe/default.nix
index 58451192396..74056bc96e0 100644
--- a/pkgs/development/compilers/haxe/default.nix
+++ b/pkgs/development/compilers/haxe/default.nix
@@ -1,20 +1,44 @@
-{ lib, stdenv, fetchgit, coreutils, ocamlPackages, zlib, pcre, neko }:
-
-let inherit (ocamlPackages) ocaml camlp4; in
+{ lib, stdenv, fetchFromGitHub, coreutils, ocaml-ng, zlib, pcre, neko, mbedtls }:
 
 let
-  generic = { version, sha256, prePatch }:
+  ocamlDependencies = version:
+    if lib.versionAtLeast version "4.0"
+    then with ocaml-ng.ocamlPackages; [
+      ocaml
+      findlib
+      sedlex_2
+      xml-light
+      ptmap
+      camlp5
+      sha
+      dune_2
+      luv
+      ocaml_extlib
+    ] else with ocaml-ng.ocamlPackages_4_05; [
+      ocaml
+      camlp4
+    ];
+
+  defaultPatch = ''
+    substituteInPlace extra/haxelib_src/src/haxelib/client/Main.hx \
+      --replace '"neko"' '"${neko}/bin/neko"'
+  '';
+
+  generic = { sha256, version, prePatch ? defaultPatch }:
     stdenv.mkDerivation {
       pname = "haxe";
       inherit version;
 
-      buildInputs = [ocaml zlib pcre neko camlp4];
+      buildInputs = [ zlib pcre neko ]
+        ++ lib.optional (lib.versionAtLeast version "4.1") [ mbedtls ]
+        ++ ocamlDependencies version;
 
-      src = fetchgit {
-        url = "https://github.com/HaxeFoundation/haxe.git";
-        inherit sha256;
+      src = fetchFromGitHub {
+        owner = "HaxeFoundation";
+        repo = "haxe";
+        rev = version;
         fetchSubmodules = true;
-        rev = "refs/tags/${version}";
+        inherit sha256;
       };
 
       inherit prePatch;
@@ -78,7 +102,7 @@ let
         description = "Programming language targeting JavaScript, Flash, NekoVM, PHP, C++";
         homepage = "https://haxe.org";
         license = with licenses; [ gpl2 bsd2 /*?*/ ];  # -> docs/license.txt
-        maintainers = [ maintainers.marcweber ];
+        maintainers = [ maintainers.marcweber maintainers.locallycompact ];
         platforms = platforms.linux ++ platforms.darwin;
       };
     };
@@ -89,15 +113,20 @@ in {
     sha256 = "1x9ay5a2llq46fww3k07jxx8h1vfpyxb522snc6702a050ki5vz3";
     prePatch = ''
       sed -i -e 's|"/usr/lib/haxe/std/";|"'"$out/lib/haxe/std/"'";\n&|g' main.ml
-      sed -i -e 's|"neko"|"${neko}/bin/neko"|g' extra/haxelib_src/src/tools/haxelib/Main.hx
+      substituteInPlace extra/haxelib_src/src/tools/haxelib/Main.hx \
+        --replace '"neko"' '"${neko}/bin/neko"'
     '';
   };
   haxe_3_4 = generic {
     version = "3.4.6";
     sha256 = "1myc4b8fwp0f9vky17wv45n34a583f5sjvajsc93f5gm1wanp4if";
     prePatch = ''
+      ${defaultPatch}
       sed -i -re 's!(let +prefix_path += +).*( +in)!\1"'"$out/"'"\2!' src/main.ml
-      sed -i -e 's|"neko"|"${neko}/bin/neko"|g' extra/haxelib_src/src/haxelib/client/Main.hx
     '';
   };
+  haxe_4_2 = generic {
+    version = "4.2.1";
+    sha256 = "sha256-0j6M21dh8DB1gC/bPYNJrVuDbJyqQbP+61ItO5RBUcA=";
+  };
 }