nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1# DARWIN-SPECIFIC OVERRIDES FOR THE HASKELL PACKAGE SET IN NIXPKGS
2
3{ pkgs, haskellLib }:
4
5let
6 inherit (pkgs) lib darwin;
7in
8
9with haskellLib;
10
11self: super:
12(
13 {
14
15 # the tests for shell-conduit on Darwin illegitimatey assume non-GNU echo
16 # see: https://github.com/psibi/shell-conduit/issues/12
17 shell-conduit = dontCheck super.shell-conduit;
18
19 conduit-extra = super.conduit-extra.overrideAttrs (drv: {
20 __darwinAllowLocalNetworking = true;
21 });
22
23 spacecookie = super.spacecookie.overrideAttrs (_: {
24 __darwinAllowLocalNetworking = true;
25 });
26
27 streaming-commons = super.streaming-commons.overrideAttrs (_: {
28 __darwinAllowLocalNetworking = true;
29 });
30
31 # Hakyll's tests are broken on Darwin (3 failures); and they require util-linux
32 hakyll = overrideCabal {
33 testToolDepends = [ ];
34 doCheck = false;
35 } super.hakyll;
36
37 double-conversion = addExtraLibrary pkgs.libcxx super.double-conversion;
38
39 # darwin doesn't have sub-second resolution
40 # https://github.com/hspec/mockery/issues/11
41 mockery = overrideCabal (drv: {
42 preCheck = ''
43 export TRAVIS=true
44 ''
45 + (drv.preCheck or "");
46 }) super.mockery;
47
48 # https://github.com/ndmitchell/shake/issues/206
49 shake = dontCheck super.shake;
50
51 filecache = dontCheck super.filecache;
52
53 # gtk/gtk3 needs to be told on Darwin to use the Quartz
54 # rather than X11 backend (see eg https://github.com/gtk2hs/gtk2hs/issues/249).
55 gtk3 = appendConfigureFlag "-f have-quartz-gtk" super.gtk3;
56 gtk = appendConfigureFlag "-f have-quartz-gtk" super.gtk;
57
58 # issues finding libcharset.h without libiconv in buildInputs on darwin.
59 with-utf8 = addExtraLibrary pkgs.libiconv super.with-utf8;
60
61 git-annex = overrideCabal (drv: {
62 # We can't use testFlags since git-annex side steps the Cabal test mechanism
63 preCheck = drv.preCheck or "" + ''
64 checkFlagsArray+=(
65 # The addurl test cases require security(1) to be in PATH which we can't
66 # provide from nixpkgs to my (@sternenseemann) knowledge.
67 "-p" "!/addurl/"
68 )
69 '';
70 }) super.git-annex;
71
72 # on*Finish tests rely on a threadDelay timing differential of 0.1s.
73 # You'd think that's plenty of time even though immediate rescheduling
74 # after threadDelay is not guaranteed. However, it appears that these
75 # tests are quite flaky on Darwin.
76 immortal = dontCheck super.immortal;
77
78 # Prevents needing to add `security_tool` as a run-time dependency for
79 # everything using x509-system to give access to the `security` executable.
80 #
81 # darwin.security_tool is broken in Mojave (#45042)
82 #
83 # We will use the system provided security for now.
84 # Beware this WILL break in sandboxes!
85 #
86 # TODO(matthewbauer): If someone really needs this to work in sandboxes,
87 # I think we can add a propagatedImpureHost dep here, but I’m hoping to
88 # get a proper fix available soonish.
89 x509-system = overrideCabal (
90 drv:
91 lib.optionalAttrs (!pkgs.stdenv.cc.nativeLibc) {
92 postPatch = ''
93 substituteInPlace System/X509/MacOS.hs --replace-fail security /usr/bin/security
94 ''
95 + (drv.postPatch or "");
96 }
97 ) super.x509-system;
98 crypton-x509-system = overrideCabal (
99 drv:
100 lib.optionalAttrs (!pkgs.stdenv.cc.nativeLibc) {
101 postPatch = ''
102 substituteInPlace System/X509/MacOS.hs --replace-fail security /usr/bin/security
103 ''
104 + (drv.postPatch or "");
105 }
106 ) super.crypton-x509-system;
107 HsOpenSSL-x509-system = overrideCabal (
108 drv:
109 lib.optionalAttrs (!pkgs.stdenv.cc.nativeLibc) {
110 postPatch = ''
111 substituteInPlace OpenSSL/X509/SystemStore/MacOSX.hs --replace-fail security /usr/bin/security
112 ''
113 + (drv.postPatch or "");
114 }
115 ) super.HsOpenSSL-x509-system;
116
117 # https://github.com/haskell-foundation/foundation/pull/412
118 foundation = dontCheck super.foundation;
119
120 # Test suite attempts to create illegal paths on HFS+
121 # https://github.com/fpco/haskell-filesystem/issues/37
122 system-fileio = dontCheck super.system-fileio;
123
124 llvm-hs = overrideCabal (oldAttrs: {
125 # One test fails on darwin.
126 doCheck = false;
127 # llvm-hs's Setup.hs file tries to add the lib/ directory from LLVM8 to
128 # the DYLD_LIBRARY_PATH environment variable. This messes up clang
129 # when called from GHC, probably because clang is version 7, but we are
130 # using LLVM8.
131 preCompileBuildDriver = ''
132 substituteInPlace Setup.hs --replace-fail "addToLdLibraryPath libDir" "pure ()"
133 ''
134 + (oldAttrs.preCompileBuildDriver or "");
135 }) super.llvm-hs;
136
137 sym = markBroken super.sym;
138
139 yesod-core = super.yesod-core.overrideAttrs (drv: {
140 # Allow access to local networking when the Darwin sandbox is enabled, so yesod-core can
141 # run tests that access localhost.
142 __darwinAllowLocalNetworking = true;
143 });
144
145 hidapi = super.hidapi.override { systemd = null; };
146
147 # Ensure the necessary frameworks are propagatedBuildInputs on darwin
148 OpenGLRaw = overrideCabal (drv: {
149 librarySystemDepends = [ ];
150 libraryHaskellDepends = drv.libraryHaskellDepends;
151 preConfigure = ''
152 frameworkPaths=($(for i in $nativeBuildInputs; do if [ -d "$i"/Library/Frameworks ]; then echo "-F$i/Library/Frameworks"; fi done))
153 frameworkPaths=$(IFS=, ; echo "''${frameworkPaths[@]}")
154 configureFlags+=$(if [ -n "$frameworkPaths" ]; then echo -n "--ghc-options=-optl=$frameworkPaths"; fi)
155 ''
156 + (drv.preConfigure or "");
157 }) super.OpenGLRaw;
158 bindings-GLFW = overrideCabal (drv: {
159 librarySystemDepends = [ ];
160 }) super.bindings-GLFW;
161
162 # cabal2nix likes to generate dependencies on hinotify when hfsevents is
163 # really required on darwin: https://github.com/NixOS/cabal2nix/issues/146.
164 hinotify = self.hfsevents;
165
166 # FSEvents API is very buggy and tests are unreliable. See
167 # http://openradar.appspot.com/10207999 and similar issues.
168 fsnotify = dontCheck super.fsnotify;
169
170 HTF = overrideCabal (drv: {
171 # GNU find is not prefixed in stdenv
172 postPatch = ''
173 substituteInPlace scripts/local-htfpp --replace-fail "find=gfind" "find=find"
174 ''
175 + (drv.postPatch or "");
176 }) super.HTF;
177
178 # conditional dependency via a cabal flag
179 cas-store = overrideCabal (drv: {
180 libraryHaskellDepends = [
181 self.kqueue
182 ]
183 ++ (drv.libraryHaskellDepends or [ ]);
184 }) super.cas-store;
185
186 # We are lacking pure pgrep at the moment for tests to work
187 tmp-postgres = dontCheck super.tmp-postgres;
188
189 # On darwin librt doesn't exist and will fail to link against,
190 # however linking against it is also not necessary there
191 GLHUI = overrideCabal (drv: {
192 postPatch = ''
193 substituteInPlace GLHUI.cabal --replace-fail " rt" ""
194 ''
195 + (drv.postPatch or "");
196 }) super.GLHUI;
197
198 SDL-image = overrideCabal (drv: {
199 # Prevent darwin-specific configuration code path being taken
200 # which doesn't work with nixpkgs' SDL libraries
201 postPatch = ''
202 substituteInPlace configure --replace-fail xDarwin noDarwinSpecialCasing
203 ''
204 + (drv.postPatch or "");
205 patches = [
206 # Work around SDL_main.h redefining main to SDL_main
207 ./patches/SDL-image-darwin-hsc.patch
208 ];
209 }) super.SDL-image;
210
211 # Prevent darwin-specific configuration code path being taken which
212 # doesn't work with nixpkgs' SDL libraries
213 SDL-mixer = overrideCabal (drv: {
214 postPatch = ''
215 substituteInPlace configure --replace-fail xDarwin noDarwinSpecialCasing
216 ''
217 + (drv.postPatch or "");
218 }) super.SDL-mixer;
219
220 # Work around SDL_main.h redefining main to SDL_main
221 SDL-ttf = appendPatch ./patches/SDL-ttf-darwin-hsc.patch super.SDL-ttf;
222
223 # Disable a bunch of test suites that fail because of darwin's case insensitive
224 # file system: When a test suite has a test suite file that has the same name
225 # as a module in scope, but in different case (e. g. hedgehog.hs and Hedgehog
226 # in scope), GHC will complain that the file name and module name differ (in
227 # the example hedgehog.hs would be Main).
228 # These failures can easily be fixed by upstream by renaming files, so we
229 # should create issues for them.
230 # https://github.com/typeclasses/aws-cloudfront-signed-cookies/issues/2
231 aws-cloudfront-signed-cookies = dontCheck super.aws-cloudfront-signed-cookies;
232
233 # https://github.com/acid-state/acid-state/issues/133
234 acid-state = dontCheck super.acid-state;
235
236 # Otherwise impure gcc is used, which is Apple's weird wrapper
237 c2hsc = addTestToolDepends [ pkgs.gcc ] super.c2hsc;
238
239 http2 = super.http2.overrideAttrs (drv: {
240 # Allow access to local networking when the Darwin sandbox is enabled, so http2 can run tests
241 # that access localhost.
242 __darwinAllowLocalNetworking = true;
243 });
244
245 # https://hydra.nixos.org/build/230964714/nixlog/1
246 inline-c-cpp = appendPatch (pkgs.fetchpatch {
247 url = "https://github.com/fpco/inline-c/commit/e8dc553b13bb847409fdced649a6a863323cff8a.patch";
248 name = "revert-use-system-cxx-std-lib.patch";
249 sha256 = "sha256-ql1/+8bvmWexyCdFR0VS4M4cY2lD0Px/9dHYLqlKyNA=";
250 revert = true;
251 stripLen = 1;
252 }) super.inline-c-cpp;
253
254 # Tests fail on macOS https://github.com/mrkkrp/zip/issues/112
255 zip = dontCheck super.zip;
256
257 http-streams = super.http-streams.overrideAttrs (drv: {
258 __darwinAllowLocalNetworking = true;
259 });
260
261 io-streams = super.io-streams.overrideAttrs (drv: {
262 __darwinAllowLocalNetworking = true;
263 });
264
265 io-streams-haproxy = super.io-streams-haproxy.overrideAttrs (drv: {
266 __darwinAllowLocalNetworking = true;
267 });
268
269 openssl-streams = super.openssl-streams.overrideAttrs (drv: {
270 __darwinAllowLocalNetworking = true;
271 });
272
273 snap = super.snap.overrideAttrs (drv: {
274 __darwinAllowLocalNetworking = true;
275 });
276
277 warp = super.warp.overrideAttrs (drv: {
278 __darwinAllowLocalNetworking = true;
279 });
280
281 ghcjs-dom-hello = overrideCabal (drv: {
282 libraryHaskellDepends = with self; [
283 jsaddle
284 jsaddle-warp
285 ];
286 executableHaskellDepends = with self; [
287 ghcjs-dom
288 jsaddle-wkwebview
289 ];
290 }) super.ghcjs-dom-hello;
291
292 jsaddle-hello = overrideCabal (drv: {
293 libraryHaskellDepends = with self; [
294 jsaddle
295 lens
296 ];
297 executableHaskellDepends = with self; [
298 jsaddle-warp
299 jsaddle-wkwebview
300 ];
301 }) super.jsaddle-hello;
302
303 jsaddle-wkwebview = overrideCabal (drv: {
304 libraryHaskellDepends = with self; [
305 aeson
306 data-default
307 jsaddle
308 ]; # cabal2nix doesn't add darwin-only deps
309 }) super.jsaddle-wkwebview;
310
311 # cabal2nix doesn't add darwin-only deps
312 reflex-dom = addBuildDepend self.jsaddle-wkwebview (
313 super.reflex-dom.override (drv: {
314 jsaddle-webkit2gtk = null;
315 })
316 );
317
318 # Remove a problematic assert, the length is sometimes 1 instead of 2 on darwin
319 di-core = overrideCabal (drv: {
320 preConfigure = ''
321 substituteInPlace test/Main.hs --replace-fail \
322 "2 @=? List.length (List.nub (List.sort (map Di.log_time logs)))" ""
323 '';
324 }) super.di-core;
325
326 # Template Haskell on Darwin fails to load an available symbol in these
327 # transitive dependencies since GHC 9.10.3.
328 # See issue https://github.com/NixOS/nixpkgs/issues/461651
329 hercules-ci-agent = overrideCabal (old: {
330 preBuild = ''
331 DYLD_INSERT_LIBRARIES="''${DYLD_INSERT_LIBRARIES:+$DYLD_INSERT_LIBRARIES:}$(pkg-config --variable=libdir nix-store)/libnixstore.dylib:$(pkg-config --variable=libdir nix-util)/libnixutil.dylib"
332 export DYLD_INSERT_LIBRARIES
333 echo "DYLD_INSERT_LIBRARIES=$DYLD_INSERT_LIBRARIES"
334 ''
335 + (old.preBuild or "");
336 }) super.hercules-ci-agent;
337
338 # Template Haskell on Darwin fails to load an available symbol in these
339 # transitive dependencies since GHC 9.10.3.
340 # See issue https://github.com/NixOS/nixpkgs/issues/461651
341 cachix = overrideCabal (old: {
342 preBuild = ''
343 DYLD_INSERT_LIBRARIES="''${DYLD_INSERT_LIBRARIES:+$DYLD_INSERT_LIBRARIES:}$(pkg-config --variable=libdir nix-store)/libnixstore.dylib:$(pkg-config --variable=libdir nix-util)/libnixutil.dylib"
344 export DYLD_INSERT_LIBRARIES
345 echo "DYLD_INSERT_LIBRARIES=$DYLD_INSERT_LIBRARIES"
346 ''
347 + (old.preBuild or "");
348 }) super.cachix;
349
350 # Require /usr/bin/security which breaks sandbox
351 http-reverse-proxy = dontCheck super.http-reverse-proxy;
352 servant-auth-server = dontCheck super.servant-auth-server;
353
354 sysinfo = dontCheck super.sysinfo;
355
356 network = super.network.overrideAttrs (drv: {
357 __darwinAllowLocalNetworking = true;
358 });
359 }
360 // lib.optionalAttrs pkgs.stdenv.hostPlatform.isAarch64 {
361 # aarch64-darwin
362
363 # Workarounds for justStaticExecutables on aarch64-darwin. Since dead code
364 # elimination barely works on aarch64-darwin, any package that has a
365 # dependency that uses a Paths_ module will incur a reference on GHC, making
366 # it fail with disallowGhcReference (which is set by justStaticExecutables).
367 #
368 # To address this, you can either manually remove the references causing this
369 # after verifying they are indeed erroneous (e.g. cabal2nix) or just disable
370 # the check, sticking with the status quo. Ideally there'll be zero cases of
371 # the latter in the future!
372 cabal2nix = overrideCabal (old: {
373 postInstall = ''
374 remove-references-to -t ${self.hpack} "''${!outputBin}/bin/cabal2nix"
375 # Note: The `data` output is needed at runtime.
376 remove-references-to -t ${self.distribution-nixpkgs.out} "''${!outputBin}/bin/hackage2nix"
377
378 ${old.postInstall or ""}
379 '';
380 }) super.cabal2nix;
381 cabal2nix-unstable = overrideCabal (old: {
382 postInstall = ''
383 remove-references-to -t ${self.hpack} "''${!outputBin}/bin/cabal2nix"
384 # Note: The `data` output is needed at runtime.
385 remove-references-to -t ${self.distribution-nixpkgs-unstable.out} "''${!outputBin}/bin/hackage2nix"
386
387 ${old.postInstall or ""}
388 '';
389 }) super.cabal2nix-unstable;
390 happy = overrideCabal (old: {
391 postInstall = ''
392 remove-references-to -t ${lib.getLib self.happy-lib} "''${!outputBin}/bin/happy"
393
394 ${old.postInstall or ""}
395 '';
396 }) super.happy;
397
398 # https://github.com/fpco/unliftio/issues/87
399 unliftio = dontCheck super.unliftio;
400 # This is the same issue as above; the rio tests call functions in unliftio
401 # that have issues as tracked in the GitHub issue above. Once the unliftio
402 # tests are fixed, we can remove this as well.
403 #
404 # We skip just the problematic tests by replacing 'it' with 'xit'.
405 rio = overrideCabal (drv: {
406 preConfigure = ''
407 sed -i 's/\bit /xit /g' test/RIO/FileSpec.hs
408 '';
409 }) super.rio;
410
411 # Don't use homebrew icu on macOS
412 # https://github.com/NixOS/nixpkgs/issues/462046
413 text-icu = disableCabalFlag "homebrew" super.text-icu;
414
415 # https://github.com/haskell-crypto/cryptonite/issues/360
416 cryptonite = appendPatch ./patches/cryptonite-remove-argon2.patch super.cryptonite;
417
418 # Build segfaults unless `fixity-th` is disabled.
419 # https://github.com/tweag/ormolu/issues/927
420 ormolu = overrideCabal (drv: {
421 libraryHaskellDepends = drv.libraryHaskellDepends ++ [ self.file-embed ];
422 }) (disableCabalFlag "fixity-th" super.ormolu);
423 fourmolu = overrideCabal (drv: {
424 libraryHaskellDepends = drv.libraryHaskellDepends ++ [ self.file-embed ];
425 }) (disableCabalFlag "fixity-th" super.fourmolu);
426
427 Agda = lib.pipe super.Agda [
428 # https://github.com/NixOS/nixpkgs/issues/149692
429 (disableCabalFlag "optimise-heavily")
430 # https://github.com/agda/agda/issues/8016
431 (appendConfigureFlag "--ghc-option=-Wwarn=deprecations")
432 ];
433
434 # https://github.com/NixOS/nixpkgs/issues/198495
435 eventsourcing-postgresql = dontCheck super.eventsourcing-postgresql;
436 gargoyle-postgresql-connect = dontCheck super.gargoyle-postgresql-connect;
437 hs-opentelemetry-instrumentation-postgresql-simple = dontCheck super.hs-opentelemetry-instrumentation-postgresql-simple;
438 moto-postgresql = dontCheck super.moto-postgresql;
439 persistent-postgresql = dontCheck super.persistent-postgresql;
440 pipes-postgresql-simple = dontCheck super.pipes-postgresql-simple;
441 postgresql-connector = dontCheck super.postgresql-connector;
442 postgresql-migration = dontCheck super.postgresql-migration;
443 postgresql-schema = dontCheck super.postgresql-schema;
444 postgresql-simple = dontCheck super.postgresql-simple;
445 postgresql-simple-interpolate = dontCheck super.postgresql-simple-interpolate;
446 postgresql-simple-migration = dontCheck super.postgresql-simple-migration;
447 postgresql-simple-url = dontCheck super.postgresql-simple-url;
448 postgresql-transactional = dontCheck super.postgresql-transactional;
449 postgrest = dontCheck super.postgrest;
450 rivet-adaptor-postgresql = dontCheck super.rivet-adaptor-postgresql;
451 tmp-proc-postgres = dontCheck super.tmp-proc-postgres;
452
453 }
454 // lib.optionalAttrs pkgs.stdenv.hostPlatform.isx86_64 {
455 # x86_64-darwin
456
457 # tests appear to be failing to link or something:
458 # https://hydra.nixos.org/build/174540882/nixlog/9
459 regex-rure = dontCheck super.regex-rure;
460 # same
461 # https://hydra.nixos.org/build/174540882/nixlog/9
462 jacinda = dontCheck super.jacinda;
463
464 # Greater floating point error on x86_64-darwin (!) for some reason
465 # https://github.com/ekmett/ad/issues/113
466 ad = overrideCabal (drv: {
467 testFlags = drv.testFlags or [ ] ++ [
468 "-p"
469 "!/issue-108/"
470 ];
471 }) super.ad;
472 }
473)