diff --git a/pkgs/development/compilers/haxe/default.nix b/pkgs/development/compilers/haxe/default.nix index 3173b8922612..8e6828bce468 100644 --- a/pkgs/development/compilers/haxe/default.nix +++ b/pkgs/development/compilers/haxe/default.nix @@ -18,6 +18,8 @@ stdenv.mkDerivation { sed -i -e 's|com.class_path <- \[|&"'"$out/lib/haxe/std/"'";|' main.ml ''; + patches = [ ./haxelib-nix.patch ]; + buildFlags = [ "all" "tools" ]; installPhase = '' @@ -26,6 +28,8 @@ stdenv.mkDerivation { cp -vr std "$out/lib/haxe" ''; + setupHook = ./setup-hook.sh; + dontStrip = true; meta = { diff --git a/pkgs/development/compilers/haxe/haxelib-nix.patch b/pkgs/development/compilers/haxe/haxelib-nix.patch new file mode 100644 index 000000000000..da7e4c8dacb8 --- /dev/null +++ b/pkgs/development/compilers/haxe/haxelib-nix.patch @@ -0,0 +1,126 @@ +diff --git a/extra/haxelib_src/src/tools/haxelib/Main.hx b/extra/haxelib_src/src/tools/haxelib/Main.hx +index a44a785..0eb811a 100644 +--- a/extra/haxelib_src/src/tools/haxelib/Main.hx ++++ b/extra/haxelib_src/src/tools/haxelib/Main.hx +@@ -996,21 +996,26 @@ class Main { + } + + function checkRec( prj : String, version : String, l : List<{ project : String, version : String, info : Infos }> ) { +- var pdir = getRepository() + Data.safe(prj); +- if( !FileSystem.exists(pdir) ) +- throw "Library "+prj+" is not installed : run 'haxelib install "+prj+"'"; +- var version = if( version != null ) version else getCurrent(pdir); +- var vdir = pdir + "/" + Data.safe(version); +- if( vdir.endsWith("dev") ) +- vdir = getDev(pdir); +- if( !FileSystem.exists(vdir) ) +- throw "Library "+prj+" version "+version+" is not installed"; +- for( p in l ) +- if( p.project == prj ) { +- if( p.version == version ) +- return; +- throw "Library "+prj+" has two version included "+version+" and "+p.version; +- } ++ var vdir = this.getNixLib(prj); ++ if (vdir == null) { ++ var pdir = getRepository() + Data.safe(prj); ++ if( !FileSystem.exists(pdir) ) ++ throw "Library "+prj+" is not installed : run 'haxelib install "+prj+"'"; ++ var version = if( version != null ) version else getCurrent(pdir); ++ var vdir = pdir + "/" + Data.safe(version); ++ if( vdir.endsWith("dev") ) ++ vdir = getDev(pdir); ++ if( !FileSystem.exists(vdir) ) ++ throw "Library "+prj+" version "+version+" is not installed"; ++ for( p in l ) ++ if( p.project == prj ) { ++ if( p.version == version ) ++ return; ++ throw "Library "+prj+" has two version included "+version+" and "+p.version; ++ } ++ } else { ++ version = null; ++ } + var json = try File.getContent(vdir+"/"+Data.JSON) catch( e : Dynamic ) null; + var inf = Data.readData(json,false); + l.add({ project : prj, version : version, info: inf }); +@@ -1025,15 +1030,21 @@ class Main { + var a = args[argcur++].split(":"); + checkRec(a[0],a[1],list); + } +- var rep = getRepository(); + for( d in list ) { +- var pdir = Data.safe(d.project)+"/"+Data.safe(d.version)+"/"; +- var dir = rep + pdir; +- try { +- dir = getDev(rep+Data.safe(d.project)); ++ var dir = this.getNixLib(d.project); ++ var pdir = Data.safe(d.project)+"/"; ++ if (dir == null) { ++ var rep = getRepository(); ++ pdir += Data.safe(d.version)+"/"; ++ dir = rep + pdir; ++ try { ++ dir = getDev(rep+Data.safe(d.project)); ++ dir = Path.addTrailingSlash(dir); ++ pdir = dir; ++ } catch( e : Dynamic ) {} ++ } else { + dir = Path.addTrailingSlash(dir); +- pdir = dir; +- } catch( e : Dynamic ) {} ++ } + var ndir = dir + "ndll"; + if( FileSystem.exists(ndir) ) { + var sysdir = ndir+"/"+Sys.systemName(); +@@ -1153,21 +1164,39 @@ class Main { + print(' Path: $devPath'); + } + ++ function getNixLib(project:String):Null ++ { ++ var hlibPath = Sys.getEnv("HAXELIB_PATH"); ++ if (hlibPath != null) { ++ for (libDir in hlibPath.split(":")) { ++ var fullpath = libDir; ++ fullpath += libDir.substr(-1, 1) == "/" ? "" : "/"; ++ fullpath += Data.safe(project); ++ if (FileSystem.exists(fullpath)) ++ return fullpath; ++ } ++ } ++ return null; ++ } ++ + function run() { +- var rep = getRepository(); + var project = param("Library"); + var temp = project.split(":"); + project = temp[0]; +- var pdir = rep + Data.safe(project); +- if( !FileSystem.exists(pdir) ) +- throw "Library "+project+" is not installed"; +- pdir += "/"; +- var version = temp[1] != null ? temp[1] : getCurrent(pdir); +- var dev = try getDev(pdir) catch ( e : Dynamic ) null; +- var vdir = dev!=null ? dev : pdir + Data.safe(version); +- var rdir = vdir + "/run.n"; +- if( !FileSystem.exists(rdir) ) +- throw "Library "+project+" version "+version+" does not have a run script"; ++ var vdir = this.getNixLib(project); ++ if (vdir == null) { ++ var rep = getRepository(); ++ var pdir = rep + Data.safe(project); ++ if( !FileSystem.exists(pdir) ) ++ throw "Library "+project+" is not installed"; ++ pdir += "/"; ++ var version = temp[1] != null ? temp[1] : getCurrent(pdir); ++ var dev = try getDev(pdir) catch ( e : Dynamic ) null; ++ vdir = dev!=null ? dev : pdir + Data.safe(version); ++ var rdir = vdir + "/run.n"; ++ if( !FileSystem.exists(rdir) ) ++ throw "Library "+project+" version "+version+" does not have a run script"; ++ } + args.push(Sys.getCwd()); + Sys.setCwd(vdir); + var cmd = "neko run.n"; diff --git a/pkgs/development/compilers/haxe/setup-hook.sh b/pkgs/development/compilers/haxe/setup-hook.sh new file mode 100644 index 000000000000..a29e04a989b6 --- /dev/null +++ b/pkgs/development/compilers/haxe/setup-hook.sh @@ -0,0 +1,5 @@ +addHaxeLibPath() { + addToSearchPath HAXELIB_PATH "$1/lib/haxe" +} + +envHooks+=(addHaxeLibPath)