Latest Haxe Version


I need to use the latest version of Haxe which is 4.2 and the current version in the nixpkgs is at 3.1.4.

So I tried to create an overlay based on the derivation for Haxe in the nixpkgs repository but it does not seem work correctly.

Any help would be apprenticed!

1 Like

I think I have a derivation that works with a 4.x release somewhere in my Laptop, will see if I can find it after I got my first coffee.

Okay, I found it. It is 4.0.5. I haven’t make it follow best practices, as I just wanted to try something out with haxe. Though as it took me about 2 hours to fiddle that derivation together, I then forgot what exactly and moved along :smiley:

{ pkgs ? import <nixpkgs> {},


 sha = pkgs.stdenv.mkDerivation rec {
   version = "1.13";

   name = "sha";

   src = pkgs.fetchFromGitHub {
     owner = "djs55";
     repo = "ocaml-sha";
     rev = "v${version}";
     sha256 = "0z1mrc4rvxvrgahxc4si6mcm5ap45fsxzmpdifylaxavdfcaqz1b";

   buildInputs = with pkgs.ocamlPackages; [ findlib dune_2 ocaml ];

   preBuild = ''
     substituteInPlace Makefile \
       --replace "build --dev" "build" \
       --replace "dune install" "dune install --prefix=$out"

   buildPhase = ''
     runHook preBuild
     dune build -p ${name}
     runHook postBuild

   installPhase = ''
     runHook preInstall
     ${pkgs.opaline}/bin/opaline -prefix $out -libdir $OCAMLFIND_DESTDIR
     runHook postInstall
 haxe = pkgs.stdenv.mkDerivation rec {
   name = "haxe";
   version = "4.0.5";

   src = pkgs.fetchgit {
     url =;
     rev = version;
     sha256 = "0f534pchdx0m057ixnk07ab4s518ica958pvpd0vfjsrxg5yjkqa";
     fetchSubmodules = true;

   buildInputs = with pkgs.ocamlPackages; with pkgs; [
     ocaml findlib ocaml_extlib camlp5 sedlex_2 xml-light ptmap sha

     zlib pcre neko

   preInstall = ''
     substituteInPlace Makefile \
       --replace "/usr/local" "$out"
in haxe

Maybe you should submit this to be included in Nixpkgs.

As I said, its not in a shape that I consider worthy to be submitted. And I currently do not have the time to make it proper.

  1. move the ocaml dep into its own place in nixpkgs
  2. make proper use of DI, instead of just taking pkgs in
  3. Do general cleanup, as a lot of the phases in each derivation are just copied pasted from around the internet without even thinking about nix idioms as I am not aware of best practices for doing OCaml packages for nix
  4. do a PR upstream that hopefully removes the necessity of patching the Makefile in the long term

Here is an updated derivation for Haxe 4.1.5 that I made:

I’d be happy to make this into a PR if it’s considered worthy to be submitted :slight_smile:

1 Like