-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
267 lines (240 loc) · 15.4 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
{
description = "Package build for mobile-core";
inputs.nixpkgs.url = "github:angerman/nixpkgs/patch-1"; # based on 21.11
inputs.haskellNix.url = "github:input-output-hk/haskell.nix/angerman/aarch64";
inputs.haskellNix.inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, haskellNix, nixpkgs, flake-utils }:
let systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; in
flake-utils.lib.eachSystem systems (system:
let pkgs = haskellNix.legacyPackages.${system}; in
let drv = pkgs': pkgs'.haskell-nix.project {
compiler-nix-name = "ghc8107";
index-state = "2020-12-15T00:00:00Z";
src = pkgs.haskell-nix.haskellLib.cleanGit {
name = "mobile-core";
src = ./.;
};
}; in
# This will package up all *.a in $out into a pkg.zip that can
# be downloaded from hydra.
let withHydraLibPkg = pkg: pkg.overrideAttrs (old: {
postInstall = ''
mkdir -p $out/_pkg
find $out/lib -name "*.a" -exec cp {} $out/_pkg \;
(cd $out/_pkg; ${pkgs.zip}/bin/zip -r -9 $out/pkg.zip *)
rm -fR $out/_pkg
mkdir -p $out/nix-support
echo "file binary-dist \"$(echo $out/*.zip)\"" \
> $out/nix-support/hydra-build-products
'';
}); in
# let mkPkg = drv: {
# # drv.override { postInstall = ''
# # mkdir -p $out/
# # zip -r -9 $out/${pkgs.stdenv.hostPlatform.config}-cardano-node-${cardano-node-info.rev or "unknown"}.zip cardano-node
# # mkdir -p $out/nix-support
# # echo "file binary-dist \"$(echo $out/*.zip)\"" \
# # > $out/nix-support/hydra-build-products
# # ''; }
# };
rec {
packages = {
"lib:mobile-core" = (drv pkgs).mobile-core.components.library;
"lib:mobile-core:static" = (drv pkgs).mobile-core.components.library.override {
enableShared = false;
ghcOptions = [ "-staticlib" ];
postInstall = ''
${pkgs.tree}/bin/tree $out
mkdir -p $out/_pkg
# copy over includes, we might want those, but maybe not.
cp -r $out/lib/*/*/include $out/_pkg/
# find the libHS...ghc-X.Y.Z.a static library; this is the
# rolled up one with all dependencies included.
find ./dist -name "libHS*-ghc*.a" -exec cp {} $out/_pkg \;
find ${pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib -name "*.a" -exec cp {} $out/_pkg \;
find ${pkgs.gmp6.override { withStatic = true; }}/lib -name "*.a" -exec cp {} $out/_pkg \;
${pkgs.tree}/bin/tree $out/_pkg
(cd $out/_pkg; ${pkgs.zip}/bin/zip -r -9 $out/pkg.zip *)
rm -fR $out/_pkg
mkdir -p $out/nix-support
echo "file binary-dist \"$(echo $out/*.zip)\"" \
> $out/nix-support/hydra-build-products
'';
};
"exe:mobile-core:mobile-core" = (drv pkgs).mobile-core.components.exes.mobile-core.override {
postInstall = ''
${pkgs.tree}/bin/tree $out
'';
};
"exe:mobile-core:mobile-core-c" = (drv pkgs).mobile-core.components.exes.mobile-core-c.override {
postInstall = ''
${pkgs.tree}/bin/tree $out
'';
};
# "lib:ffi:static" = pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; });
# "lib:gmp:static" = pkgs.gmp6.override { withStatic = true; };
} // ({ "x86_64-linux" = let muslPkgs = pkgs.pkgsCross.musl64;
androidPkgs = pkgs.pkgsCross.aarch64-android;
# For some reason building libiconv with nixpgks android setup produces
# LANGINFO_CODESET to be found, which is not compatible with android sdk 23;
# so we'll patch up iconv to not include that.
androidIconv = (androidPkgs.libiconv.override { enableStatic = true; }).overrideAttrs (old: {
postConfigure = ''
echo "#undef HAVE_LANGINFO_CODESET" >> libcharset/config.h
echo "#undef HAVE_LANGINFO_CODESET" >> lib/config.h
'';
});
# Similarly to icovn, for reasons beyond my current knowledge, nixpkgs andorid
# toolchain makes configure believe we have MEMFD_CREATE, which we don't in
# sdk 23.
androidFFI = androidPkgs.libffi.overrideAttrs (old: {
dontDisableStatic = true;
hardeningDisable = [ "fortify" ];
postConfigure = ''
echo "#undef HAVE_MEMFD_CREATE" >> aarch64-unknown-linux-android/fficonfig.h
'';
});
in {
"ghcjs:lib:mobile-core" = (drv pkgs.pkgsCross.ghcjs).mobile-core.components.library;
# "musl64:lib:ffi:static" = muslPkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; });
# "musl64:lib:gmp:static" = muslPkgs.gmp6.override { withStatic = true; };
"musl64:lib:mobile-core" = (drv muslPkgs).mobile-core.components.library;
"musl64:exe:mobile-core:mobile-core" = (drv muslPkgs).mobile-core.components.exes.mobile-core;
"musl64:exe:mobile-core:mobile-core-c" = (drv muslPkgs).mobile-core.components.exes.mobile-core-c;
"musl64:lib:mobile-core:smallAddressSpace" = (drv muslPkgs).mobile-core.components.library.override {
smallAddressSpace = true; enableShared = false;
ghcOptions = [ "-staticlib" ];
postInstall = ''
${pkgs.tree}/bin/tree $out
mkdir -p $out/_pkg
# copy over includes, we might want those, but maybe not.
cp -r $out/lib/*/*/include $out/_pkg/
# find the libHS...ghc-X.Y.Z.a static library; this is the
# rolled up one with all dependencies included.
find ./dist -name "libHS*-ghc*.a" -exec cp {} $out/_pkg \;
find ${muslPkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib -name "*.a" -exec cp {} $out/_pkg \;
find ${muslPkgs.gmp6.override { withStatic = true; }}/lib -name "*.a" -exec cp {} $out/_pkg \;
find ${muslPkgs.stdenv.cc.libc}/lib -name "*.a" -exec cp {} $out/_pkg \;
${pkgs.tree}/bin/tree $out/_pkg
(cd $out/_pkg; ${pkgs.zip}/bin/zip -r -9 $out/pkg.zip *)
rm -fR $out/_pkg
mkdir -p $out/nix-support
echo "file binary-dist \"$(echo $out/*.zip)\"" \
> $out/nix-support/hydra-build-products
'';
};
"aarch64-android:lib:ffi:static" = withHydraLibPkg androidFFI;
# "aarch64-android:lib:gmp:static" = androidPkgs.gmp6.override { withStatic = true; };
"aarch64-android:lib:iconv:static" = withHydraLibPkg androidIconv;
"aarch64-android:lib:mobile-core" = (drv androidPkgs).mobile-core.components.library;
"aarch64-android:exe:mobile-core:mobile-core" = (drv androidPkgs).mobile-core.components.exes.mobile-core;
"aarch64-android:exe:mobile-core:mobile-core-c" = (drv androidPkgs).mobile-core.components.exes.mobile-core-c;
"aarch64-android:lib:mobile-core:smallAddressSpace" = (drv androidPkgs).mobile-core.components.library.override {
smallAddressSpace = true; enableShared = false;
ghcOptions = [ "-staticlib" ];
postInstall = ''
${pkgs.tree}/bin/tree $out
mkdir -p $out/_pkg
# copy over includes, we might want those, but maybe not.
cp -r $out/lib/*/*/include $out/_pkg/
# find the libHS...ghc-X.Y.Z.a static library; this is the
# rolled up one with all dependencies included.
find ./dist -name "libHS*-ghc*.a" -exec cp {} $out/_pkg \;
find ${androidFFI}/lib -name "*.a" -exec cp {} $out/_pkg \;
find ${androidPkgs.gmp6.override { withStatic = true; }}/lib -name "*.a" -exec cp {} $out/_pkg \;
find ${androidIconv}/lib -name "*.a" -exec cp {} $out/_pkg \;
find ${androidPkgs.stdenv.cc.libc}/lib -name "*.a" -exec cp {} $out/_pkg \;
${pkgs.tree}/bin/tree $out/_pkg
(cd $out/_pkg; ${pkgs.zip}/bin/zip -r -9 $out/pkg.zip *)
rm -fR $out/_pkg
mkdir -p $out/nix-support
echo "file binary-dist \"$(echo $out/*.zip)\"" \
> $out/nix-support/hydra-build-products
'';
};
};
"aarch64-linux" = let muslPkgs = pkgs.pkgsCross.aarch64-multiplatform-musl; androidPkgs = pkgs.pkgsCross.aarch64-android; in {
# "musl64:lib:ffi:static" = muslPkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; });
# "musl64:lib:gmp:static" = muslPkgs.gmp6.override { withStatic = true; };
"musl64:lib:mobile-core" = (drv muslPkgs).mobile-core.components.library;
"musl64:exe:mobile-core:mobile-core" = (drv muslPkgs).mobile-core.components.exes.mobile-core;
"musl64:exe:mobile-core:mobile-core-c" = (drv muslPkgs).mobile-core.components.exes.mobile-core-c;
"musl64:lib:mobile-core:smallAddressSpace" = (drv muslPkgs).mobile-core.components.library.override {
smallAddressSpace = true; enableShared = false;
ghcOptions = [ "-staticlib" ];
postInstall = ''
${pkgs.tree}/bin/tree $out
mkdir -p $out/_pkg
# copy over includes, we might want those, but maybe not.
cp -r $out/lib/*/*/include $out/_pkg/
# find the libHS...ghc-X.Y.Z.a static library; this is the
# rolled up one with all dependencies included.
find ./dist -name "libHS*-ghc*.a" -exec cp {} $out/_pkg \;
find ${muslPkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib -name "*.a" -exec cp {} $out/_pkg \;
find ${muslPkgs.gmp6.override { withStatic = true; }}/lib -name "*.a" -exec cp {} $out/_pkg \;
find ${muslPkgs.stdenv.cc.libc}/lib -name "*.a" -exec cp {} $out/_pkg \;
${pkgs.tree}/bin/tree $out/_pkg
(cd $out/_pkg; ${pkgs.zip}/bin/zip -r -9 $out/pkg.zip *)
rm -fR $out/_pkg
mkdir -p $out/nix-support
echo "file binary-dist \"$(echo $out/*.zip)\"" \
> $out/nix-support/hydra-build-products
'';
};
# "android64:exe:mobile-core:mobile-core" = (drv androidPkgs).mobile-core.components.exes.mobile-core;
# "android64:exe:mobile-core:mobile-core-c" = (drv androidPkgs).mobile-core.components.exes.mobile-core-c;
# "android64:lib:mobile-core:smallAddressSpace" = (drv androidPkgs).mobile-core.components.library.override {
# smallAddressSpace = true; enableShared = false;
# ghcOptions = [ "-staticlib" ];
# postInstall = ''
# ${pkgs.tree}/bin/tree $out
# mkdir -p $out/_pkg
# # copy over includes, we might want those, but maybe not.
# cp -r $out/lib/*/*/include $out/_pkg/
# # find the libHS...ghc-X.Y.Z.a static library; this is the
# # rolled up one with all dependencies included.
# find ./dist -name "libHS*-ghc*.a" -exec cp {} $out/_pkg \;
# find ${androidPkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib -name "*.a" -exec cp {} $out/_pkg \;
# find ${androidPkgs.gmp6.override { withStatic = true; }}/lib -name "*.a" -exec cp {} $out/_pkg \;
# ${pkgs.tree}/bin/tree $out/_pkg
# (cd $out/_pkg; ${pkgs.zip}/bin/zip -r -9 $out/pkg.zip *)
# rm -fR $out/_pkg
# mkdir -p $out/nix-support
# echo "file binary-dist \"$(echo $out/*.zip)\"" \
# > $out/nix-support/hydra-build-products
# '';
# };
};
"aarch64-darwin" = {
# "lib:ffi:static" = pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; });
# "lib:gmp:static" = pkgs.gmp6.override { withStatic = true; };
"lib:mobile-core:smallAddressSpace:static" = (drv pkgs).mobile-core.components.library.override {
smallAddressSpace = true; enableShared = false;
ghcOptions = [ "-staticlib" ];
postInstall = ''
${pkgs.tree}/bin/tree $out
mkdir -p $out/_pkg
# copy over includes, we might want those, but maybe not.
cp -r $out/lib/*/*/include $out/_pkg/
# find the libHS...ghc-X.Y.Z.a static library; this is the
# rolled up one with all dependencies included.
find ./dist -name "libHS*-ghc*.a" -exec cp {} $out/_pkg \;
find ${pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib -name "*.a" -exec cp {} $out/_pkg \;
find ${pkgs.gmp6.override { withStatic = true; }}/lib -name "*.a" -exec cp {} $out/_pkg \;
# There is no static libc
${pkgs.tree}/bin/tree $out/_pkg
(cd $out/_pkg; ${pkgs.zip}/bin/zip -r -9 $out/pkg.zip *)
rm -fR $out/_pkg
mkdir -p $out/nix-support
echo "file binary-dist \"$(echo $out/*.zip)\"" \
> $out/nix-support/hydra-build-products
'';
};
};
}.${system} or {});
# build all packages in hydra.
hydraJobs = packages;
}
);
}