nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchzip,
5 fetchFromGitHub,
6 haxe,
7 neko,
8 jdk,
9 mono,
10}:
11
12let
13 withCommas = lib.replaceStrings [ "." ] [ "," ];
14
15 # simulate "haxelib dev $libname ."
16 simulateHaxelibDev = libname: ''
17 devrepo=$(mktemp -d)
18 mkdir -p "$devrepo/${withCommas libname}"
19 echo $(pwd) > "$devrepo/${withCommas libname}/.dev"
20 export HAXELIB_PATH="$HAXELIB_PATH:$devrepo"
21 '';
22
23 installLibHaxe =
24 {
25 libname,
26 version,
27 files ? "*",
28 }:
29 ''
30 mkdir -p "$out/lib/haxe/${withCommas libname}/${withCommas version}"
31 echo -n "${version}" > $out/lib/haxe/${withCommas libname}/.current
32 cp -dpR ${files} "$out/lib/haxe/${withCommas libname}/${withCommas version}/"
33 '';
34
35 buildHaxeLib =
36 {
37 libname,
38 version,
39 sha256,
40 meta,
41 ...
42 }@attrs:
43 stdenv.mkDerivation (
44 attrs
45 // {
46 name = "${libname}-${version}";
47
48 buildInputs = (attrs.buildInputs or [ ]) ++ [
49 haxe
50 neko
51 ]; # for setup-hook.sh to work
52 src = fetchzip rec {
53 name = "${libname}-${version}";
54 url = "http://lib.haxe.org/files/3.0/${withCommas name}.zip";
55 inherit sha256;
56 stripRoot = false;
57 };
58
59 installPhase =
60 attrs.installPhase or ''
61 runHook preInstall
62 (
63 if [ $(ls $src | wc -l) == 1 ]; then
64 cd $src/* || cd $src
65 else
66 cd $src
67 fi
68 ${installLibHaxe { inherit libname version; }}
69 )
70 runHook postInstall
71 '';
72
73 meta = {
74 homepage = "http://lib.haxe.org/p/${libname}";
75 license = lib.licenses.bsd2;
76 platforms = lib.platforms.all;
77 description = throw "please write meta.description";
78 }
79 // attrs.meta;
80 }
81 );
82in
83{
84 format = buildHaxeLib {
85 libname = "format";
86 version = "3.5.0";
87 sha256 = "sha256-5vZ7b+P74uGx0Gb7X/+jbsx5048dO/jv5nqCDtw5y/A=";
88 meta.description = "Haxe library for supporting different file formats";
89 };
90
91 heaps = buildHaxeLib {
92 libname = "heaps";
93 version = "1.9.1";
94 sha256 = "sha256-i5EIKnph80eEEHvGXDXhIL4t4+RW7OcUV5zb2f3ItlI=";
95 meta.description = "GPU game framework";
96 };
97
98 hlopenal = buildHaxeLib {
99 libname = "hlopenal";
100 version = "1.5.0";
101 sha256 = "sha256-mJWFGBJPPAhVwsB2HzMfk4szSyjMT4aw543YhVqIan4=";
102 meta.description = "OpenAL support for Haxe/HL";
103 };
104
105 hlsdl = buildHaxeLib {
106 libname = "hlsdl";
107 version = "1.10.0";
108 sha256 = "sha256-kmC2EMDy1mv0jFjwDj+m0CUvKal3V7uIGnMxJBRYGms=";
109 meta.description = "SDL/GL support for Haxe/HL";
110 };
111
112 hxcpp = buildHaxeLib rec {
113 libname = "hxcpp";
114 version = "4.1.15";
115 sha256 = "1ybxcvwi4655563fjjgy6xv5c78grjxzadmi3l1ghds48k1rh50p";
116 postFixup = ''
117 for f in $out/lib/haxe/${withCommas libname}/${withCommas version}/{,project/libs/nekoapi/}bin/Linux{,64}/*; do
118 chmod +w "$f"
119 patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) "$f" || true
120 patchelf --set-rpath ${lib.makeLibraryPath [ stdenv.cc.cc ]} "$f" || true
121 done
122 '';
123 meta.description = "Runtime support library for the Haxe C++ backend";
124 };
125
126 hxjava = buildHaxeLib {
127 libname = "hxjava";
128 version = "3.2.0";
129 sha256 = "1vgd7qvsdxlscl3wmrrfi5ipldmr4xlsiwnj46jz7n6izff5261z";
130 meta.description = "Support library for the Java backend of the Haxe compiler";
131 propagatedBuildInputs = [ jdk ];
132 };
133
134 hxcs = buildHaxeLib {
135 libname = "hxcs";
136 version = "3.4.0";
137 sha256 = "0f5vgp2kqnpsbbkn2wdxmjf7xkl0qhk9lgl9kb8d5wdy89nac6q6";
138 meta.description = "Support library for the C# backend of the Haxe compiler";
139 propagatedBuildInputs = [ mono ];
140 };
141
142 hxnodejs_4 = buildHaxeLib {
143 libname = "hxnodejs";
144 version = "4.0.9";
145 sha256 = "0b7ck48nsxs88sy4fhhr0x1bc8h2ja732zzgdaqzxnh3nir0bajm";
146 meta.description = "Extern definitions for node.js 4.x";
147 };
148
149 hxnodejs_6 =
150 let
151 libname = "hxnodejs";
152 version = "6.9.0";
153 in
154 stdenv.mkDerivation {
155 name = "${libname}-${version}";
156 src = fetchFromGitHub {
157 owner = "HaxeFoundation";
158 repo = "hxnodejs";
159 rev = "cf80c6a077e705d39f752418e95555b346f4d9b2";
160 sha256 = "0mdiacr5b2m8jrlgyd2d3vp1fha69lcfb67x4ix7l7zfi8g460gs";
161 };
162 installPhase = installLibHaxe { inherit libname version; };
163 meta = {
164 homepage = "http://lib.haxe.org/p/${libname}";
165 license = lib.licenses.bsd2;
166 platforms = lib.platforms.all;
167 description = "Extern definitions for node.js 6.9";
168 };
169 };
170}