1 # DARWIN-SPECIFIC OVERRIDES FOR THE HASKELL PACKAGE SET IN NIXPKGS
6 inherit (pkgs) lib darwin;
13 # the tests for shell-conduit on Darwin illegitimatey assume non-GNU echo
14 # see: https://github.com/psibi/shell-conduit/issues/12
15 shell-conduit = dontCheck super.shell-conduit;
17 conduit-extra = super.conduit-extra.overrideAttrs (drv: {
18 __darwinAllowLocalNetworking = true;
21 streaming-commons = super.streaming-commons.overrideAttrs (_: {
22 __darwinAllowLocalNetworking = true;
25 halive = addBuildDepend darwin.apple_sdk.frameworks.AppKit super.halive;
27 # Hakyll's tests are broken on Darwin (3 failures); and they require util-linux
28 hakyll = overrideCabal {
33 barbly = addBuildDepend darwin.apple_sdk.frameworks.AppKit super.barbly;
35 double-conversion = addExtraLibrary pkgs.libcxx super.double-conversion;
37 streamly = addBuildDepend darwin.apple_sdk.frameworks.Cocoa super.streamly;
39 apecs-physics = addPkgconfigDepends [
40 darwin.apple_sdk.frameworks.ApplicationServices
41 ] super.apecs-physics;
43 # Framework deps are hidden behind a flag
44 hmidi = addExtraLibraries [
45 darwin.apple_sdk.frameworks.CoreFoundation
46 darwin.apple_sdk.frameworks.CoreAudio
47 darwin.apple_sdk.frameworks.CoreMIDI
50 # "erf table" test fails on Darwin
51 # https://github.com/bos/math-functions/issues/63
52 math-functions = dontCheck super.math-functions;
54 # darwin doesn't have sub-second resolution
55 # https://github.com/hspec/mockery/issues/11
56 mockery = overrideCabal (drv: {
59 '' + (drv.preCheck or "");
62 # https://github.com/ndmitchell/shake/issues/206
63 shake = dontCheck super.shake;
65 filecache = dontCheck super.filecache;
67 # gtk/gtk3 needs to be told on Darwin to use the Quartz
68 # rather than X11 backend (see eg https://github.com/gtk2hs/gtk2hs/issues/249).
69 gtk3 = appendConfigureFlag "-f have-quartz-gtk" super.gtk3;
70 gtk = appendConfigureFlag "-f have-quartz-gtk" super.gtk;
72 OpenAL = addExtraLibrary darwin.apple_sdk.frameworks.OpenAL super.OpenAL;
74 al = overrideCabal (drv: {
75 libraryFrameworkDepends = [
76 darwin.apple_sdk.frameworks.OpenAL
77 ] ++ (drv.libraryFrameworkDepends or []);
80 proteaaudio = addExtraLibrary darwin.apple_sdk.frameworks.AudioToolbox super.proteaaudio;
82 # issues finding libcharset.h without libiconv in buildInputs on darwin.
83 with-utf8 = addExtraLibrary pkgs.libiconv super.with-utf8;
84 with-utf8_1_1_0_0 = addExtraLibrary pkgs.libiconv super.with-utf8_1_1_0_0;
86 git-annex = overrideCabal (drv: {
87 # We can't use testFlags since git-annex side steps the Cabal test mechanism
88 preCheck = drv.preCheck or "" + ''
90 # The addurl test cases require security(1) to be in PATH which we can't
91 # provide from nixpkgs to my (@sternenseemann) knowledge.
97 # on*Finish tests rely on a threadDelay timing differential of 0.1s.
98 # You'd think that's plenty of time even though immediate rescheduling
99 # after threadDelay is not guaranteed. However, it appears that these
100 # tests are quite flaky on Darwin.
101 immortal = dontCheck super.immortal;
103 # Prevents needing to add `security_tool` as a run-time dependency for
104 # everything using x509-system to give access to the `security` executable.
106 # darwin.security_tool is broken in Mojave (#45042)
108 # We will use the system provided security for now.
109 # Beware this WILL break in sandboxes!
111 # TODO(matthewbauer): If someone really needs this to work in sandboxes,
112 # I think we can add a propagatedImpureHost dep here, but I’m hoping to
113 # get a proper fix available soonish.
114 x509-system = overrideCabal (drv:
115 lib.optionalAttrs (!pkgs.stdenv.cc.nativeLibc) {
117 substituteInPlace System/X509/MacOS.hs --replace security /usr/bin/security
118 '' + (drv.postPatch or "");
119 }) super.x509-system;
120 crypton-x509-system = overrideCabal (drv:
121 lib.optionalAttrs (!pkgs.stdenv.cc.nativeLibc) {
123 substituteInPlace System/X509/MacOS.hs --replace security /usr/bin/security
124 '' + (drv.postPatch or "");
125 }) super.crypton-x509-system;
127 # https://github.com/haskell-foundation/foundation/pull/412
128 foundation = dontCheck super.foundation;
130 llvm-hs = overrideCabal (oldAttrs: {
131 # One test fails on darwin.
133 # llvm-hs's Setup.hs file tries to add the lib/ directory from LLVM8 to
134 # the DYLD_LIBRARY_PATH environment variable. This messes up clang
135 # when called from GHC, probably because clang is version 7, but we are
137 preCompileBuildDriver = ''
138 substituteInPlace Setup.hs --replace "addToLdLibraryPath libDir" "pure ()"
139 '' + (oldAttrs.preCompileBuildDriver or "");
142 sym = markBroken super.sym;
144 yesod-bin = addBuildDepend darwin.apple_sdk.frameworks.Cocoa super.yesod-bin;
146 yesod-core = super.yesod-core.overrideAttrs (drv: {
147 # Allow access to local networking when the Darwin sandbox is enabled, so yesod-core can
148 # run tests that access localhost.
149 __darwinAllowLocalNetworking = true;
154 darwin.apple_sdk.frameworks.AppKit
155 darwin.apple_sdk.frameworks.IOKit
156 darwin.apple_sdk.frameworks.CoreFoundation
158 (super.hidapi.override { systemd = null; });
160 hmatrix = addBuildDepend darwin.apple_sdk.frameworks.Accelerate super.hmatrix;
162 blas-hs = overrideCabal (drv: {
163 libraryFrameworkDepends = [
164 darwin.apple_sdk.frameworks.Accelerate
165 ] ++ (drv.libraryFrameworkDepends or []);
168 # Ensure the necessary frameworks are propagatedBuildInputs on darwin
169 OpenGLRaw = overrideCabal (drv: {
170 librarySystemDepends = [];
171 libraryHaskellDepends = drv.libraryHaskellDepends ++ [
172 darwin.apple_sdk.frameworks.OpenGL
175 frameworkPaths=($(for i in $nativeBuildInputs; do if [ -d "$i"/Library/Frameworks ]; then echo "-F$i/Library/Frameworks"; fi done))
176 frameworkPaths=$(IFS=, ; echo "''${frameworkPaths[@]}")
177 configureFlags+=$(if [ -n "$frameworkPaths" ]; then echo -n "--ghc-options=-optl=$frameworkPaths"; fi)
178 '' + (drv.preConfigure or "");
180 GLURaw = overrideCabal (drv: {
181 librarySystemDepends = [];
182 libraryHaskellDepends = drv.libraryHaskellDepends ++ [
183 darwin.apple_sdk.frameworks.OpenGL
186 bindings-GLFW = overrideCabal (drv: {
187 librarySystemDepends = [];
188 libraryHaskellDepends = drv.libraryHaskellDepends ++ [
189 darwin.apple_sdk.frameworks.AGL
190 darwin.apple_sdk.frameworks.Cocoa
191 darwin.apple_sdk.frameworks.OpenGL
192 darwin.apple_sdk.frameworks.IOKit
193 darwin.apple_sdk.frameworks.Kernel
194 darwin.apple_sdk.frameworks.CoreVideo
197 }) super.bindings-GLFW;
198 OpenCL = overrideCabal (drv: {
199 librarySystemDepends = [];
200 libraryHaskellDepends = drv.libraryHaskellDepends ++ [
201 darwin.apple_sdk.frameworks.OpenCL
205 # cabal2nix likes to generate dependencies on hinotify when hfsevents is
206 # really required on darwin: https://github.com/NixOS/cabal2nix/issues/146.
207 hinotify = self.hfsevents;
209 # FSEvents API is very buggy and tests are unreliable. See
210 # http://openradar.appspot.com/10207999 and similar issues.
211 fsnotify = addBuildDepend darwin.apple_sdk.frameworks.Cocoa
212 (dontCheck super.fsnotify);
214 FractalArt = overrideCabal (drv: {
215 librarySystemDepends = [
217 darwin.apple_sdk.frameworks.AppKit
218 ] ++ (drv.librarySystemDepends or []);
221 arbtt = overrideCabal (drv: {
222 librarySystemDepends = [
223 darwin.apple_sdk.frameworks.Foundation
224 darwin.apple_sdk.frameworks.Carbon
225 darwin.apple_sdk.frameworks.IOKit
226 ] ++ (drv.librarySystemDepends or []);
229 HTF = overrideCabal (drv: {
230 # GNU find is not prefixed in stdenv
232 substituteInPlace scripts/local-htfpp --replace "find=gfind" "find=find"
233 '' + (drv.postPatch or "");
236 # conditional dependency via a cabal flag
237 cas-store = overrideCabal (drv: {
238 libraryHaskellDepends = [
240 ] ++ (drv.libraryHaskellDepends or []);
243 # We are lacking pure pgrep at the moment for tests to work
244 tmp-postgres = dontCheck super.tmp-postgres;
246 # On darwin librt doesn't exist and will fail to link against,
247 # however linking against it is also not necessary there
248 GLHUI = overrideCabal (drv: {
250 substituteInPlace GLHUI.cabal --replace " rt" ""
251 '' + (drv.postPatch or "");
254 SDL-image = overrideCabal (drv: {
255 # Prevent darwin-specific configuration code path being taken
256 # which doesn't work with nixpkgs' SDL libraries
258 substituteInPlace configure --replace xDarwin noDarwinSpecialCasing
259 '' + (drv.postPatch or "");
261 # Work around SDL_main.h redefining main to SDL_main
262 ./patches/SDL-image-darwin-hsc.patch
266 # Prevent darwin-specific configuration code path being taken which
267 # doesn't work with nixpkgs' SDL libraries
268 SDL-mixer = overrideCabal (drv: {
270 substituteInPlace configure --replace xDarwin noDarwinSpecialCasing
271 '' + (drv.postPatch or "");
274 # Work around SDL_main.h redefining main to SDL_main
275 SDL-ttf = appendPatch ./patches/SDL-ttf-darwin-hsc.patch super.SDL-ttf;
277 # Disable a bunch of test suites that fail because of darwin's case insensitive
278 # file system: When a test suite has a test suite file that has the same name
279 # as a module in scope, but in different case (e. g. hedgehog.hs and Hedgehog
280 # in scope), GHC will complain that the file name and module name differ (in
281 # the example hedgehog.hs would be Main).
282 # These failures can easily be fixed by upstream by renaming files, so we
283 # should create issues for them.
284 # https://github.com/typeclasses/aws-cloudfront-signed-cookies/issues/2
285 aws-cloudfront-signed-cookies = dontCheck super.aws-cloudfront-signed-cookies;
287 # https://github.com/acid-state/acid-state/issues/133
288 acid-state = dontCheck super.acid-state;
290 # Otherwise impure gcc is used, which is Apple's weird wrapper
291 c2hsc = addTestToolDepends [ pkgs.gcc ] super.c2hsc;
293 http-client-tls = overrideCabal (drv: {
295 # This comment has been inserted, so the derivation hash changes, forcing
296 # a rebuild of this derivation which has succeeded to build on Hydra before,
297 # but apparently been corrupted, causing reverse dependencies to fail.
299 # This workaround can be removed upon the next darwin stdenv rebuild,
300 # presumably https://github.com/NixOS/nixpkgs/pull/152850 or the next
301 # full haskellPackages rebuild.
302 '' + drv.postPatch or "";
303 }) super.http-client-tls;
305 http2 = super.http2.overrideAttrs (drv: {
306 # Allow access to local networking when the Darwin sandbox is enabled, so http2 can run tests
307 # that access localhost.
308 __darwinAllowLocalNetworking = true;
311 # network requires `IP_RECVTOS`, which was added in 10.15.
313 if lib.versionOlder (lib.getVersion pkgs.apple-sdk) "10.15" then
314 addBuildDepend pkgs.apple-sdk_10_15 super.network
318 foldl = overrideCabal (drv: {
320 # This comment has been inserted, so the derivation hash changes, forcing
321 # a rebuild of this derivation which has succeeded to build on Hydra before,
322 # but apparently been corrupted, causing reverse dependencies to fail.
324 # This workaround can be removed upon the next darwin stdenv rebuild,
325 # presumably https://github.com/NixOS/nixpkgs/pull/152850 or the next
326 # full haskellPackages rebuild.
327 '' + drv.postPatch or "";
330 # https://hydra.nixos.org/build/230964714/nixlog/1
331 inline-c-cpp = appendPatch (pkgs.fetchpatch {
332 url = "https://github.com/fpco/inline-c/commit/e8dc553b13bb847409fdced649a6a863323cff8a.patch";
333 name = "revert-use-system-cxx-std-lib.patch";
334 sha256 = "sha256-ql1/+8bvmWexyCdFR0VS4M4cY2lD0Px/9dHYLqlKyNA=";
337 }) super.inline-c-cpp;
339 # Tests fail on macOS https://github.com/mrkkrp/zip/issues/112
340 zip = dontCheck super.zip;
342 snap = super.snap.overrideAttrs (drv: {
343 __darwinAllowLocalNetworking = true;
346 warp = super.warp.overrideAttrs (drv: {
347 __darwinAllowLocalNetworking = true;
350 ghcjs-dom-hello = overrideCabal (drv: {
351 libraryHaskellDepends = with self; [ jsaddle jsaddle-warp ];
352 executableHaskellDepends = with self; [ ghcjs-dom jsaddle-wkwebview ];
353 }) super.ghcjs-dom-hello;
355 jsaddle-hello = overrideCabal (drv: {
356 libraryHaskellDepends = with self; [ jsaddle lens ];
357 executableHaskellDepends = with self; [ jsaddle-warp jsaddle-wkwebview ];
358 }) super.jsaddle-hello;
360 jsaddle-wkwebview = overrideCabal (drv: {
361 libraryFrameworkDepends = with pkgs.buildPackages.darwin.apple_sdk.frameworks; [ Cocoa WebKit ];
362 libraryHaskellDepends = with self; [ aeson data-default jsaddle ]; # cabal2nix doesn't add darwin-only deps
363 }) super.jsaddle-wkwebview;
365 # cabal2nix doesn't add darwin-only deps
366 reflex-dom = addBuildDepend self.jsaddle-wkwebview (super.reflex-dom.override (drv: {
367 jsaddle-webkit2gtk = null;
370 # Remove a problematic assert, the length is sometimes 1 instead of 2 on darwin
371 di-core = overrideCabal (drv: {
373 substituteInPlace test/Main.hs --replace \
374 "2 @=? List.length (List.nub (List.sort (map Di.log_time logs)))" ""
378 } // lib.optionalAttrs pkgs.stdenv.hostPlatform.isAarch64 { # aarch64-darwin
380 # Workarounds for justStaticExecutables on aarch64-darwin. Since dead code
381 # elimination barely works on aarch64-darwin, any package that has a
382 # dependency that uses a Paths_ module will incur a reference on GHC, making
383 # it fail with disallowGhcReference (which is set by justStaticExecutables).
385 # To address this, you can either manually remove the references causing this
386 # after verifying they are indeed erroneous (e.g. cabal2nix) or just disable
387 # the check, sticking with the status quo. Ideally there'll be zero cases of
388 # the latter in the future!
390 lib.mapAttrs (_: overrideCabal (old: {
392 remove-references-to -t ${self.hpack} "$out/bin/cabal2nix"
393 # Note: The `data` output is needed at runtime.
394 remove-references-to -t ${self.distribution-nixpkgs.out} "$out/bin/hackage2nix"
396 ${old.postInstall or ""}
399 ) cabal2nix cabal2nix-unstable;
401 # https://github.com/fpco/unliftio/issues/87
402 unliftio = dontCheck super.unliftio;
403 # This is the same issue as above; the rio tests call functions in unliftio
404 # that have issues as tracked in the GitHub issue above. Once the unliftio
405 # tests are fixed, we can remove this as well.
407 # We skip just the problematic tests by replacing 'it' with 'xit'.
408 rio = overrideCabal (drv: {
410 sed -i 's/\bit /xit /g' test/RIO/FileSpec.hs
414 # https://github.com/haskell-crypto/cryptonite/issues/360
415 cryptonite = appendPatch ./patches/cryptonite-remove-argon2.patch super.cryptonite;
417 # Build segfaults unless `fixity-th` is disabled.
418 # https://github.com/tweag/ormolu/issues/927
419 ormolu = overrideCabal (drv: {
420 libraryHaskellDepends = drv.libraryHaskellDepends ++ [ self.file-embed ];
421 }) (disableCabalFlag "fixity-th" super.ormolu);
422 fourmolu = overrideCabal (drv: {
423 libraryHaskellDepends = drv.libraryHaskellDepends ++ [ self.file-embed ];
424 }) (disableCabalFlag "fixity-th" super.fourmolu);
426 # https://github.com/NixOS/nixpkgs/issues/149692
427 Agda = disableCabalFlag "optimise-heavily" super.Agda;
429 # https://github.com/NixOS/nixpkgs/issues/198495
430 eventsourcing-postgresql = dontCheck super.eventsourcing-postgresql;
431 gargoyle-postgresql-connect = dontCheck super.gargoyle-postgresql-connect;
432 hs-opentelemetry-instrumentation-postgresql-simple = dontCheck super.hs-opentelemetry-instrumentation-postgresql-simple;
433 moto-postgresql = dontCheck super.moto-postgresql;
434 persistent-postgresql = dontCheck super.persistent-postgresql;
435 pipes-postgresql-simple = dontCheck super.pipes-postgresql-simple;
436 postgresql-connector = dontCheck super.postgresql-connector;
437 postgresql-migration = dontCheck super.postgresql-migration;
438 postgresql-schema = dontCheck super.postgresql-schema;
439 postgresql-simple = dontCheck super.postgresql-simple;
440 postgresql-simple-interpolate = dontCheck super.postgresql-simple-interpolate;
441 postgresql-simple-migration = dontCheck super.postgresql-simple-migration;
442 postgresql-simple-url = dontCheck super.postgresql-simple-url;
443 postgresql-transactional = dontCheck super.postgresql-transactional;
444 postgrest = dontCheck super.postgrest;
445 rivet-adaptor-postgresql = dontCheck super.rivet-adaptor-postgresql;
446 tmp-proc-postgres = dontCheck super.tmp-proc-postgres;
448 } // lib.optionalAttrs pkgs.stdenv.hostPlatform.isx86_64 { # x86_64-darwin
450 # Work around store corruption on one of our Hydra builders
451 # https://github.com/NixOS/nixpkgs/issues/356741
452 filepath-bytestring = triggerRebuild 1 super.filepath-bytestring;
453 magic = triggerRebuild 1 super.magic;
455 # tests appear to be failing to link or something:
456 # https://hydra.nixos.org/build/174540882/nixlog/9
457 regex-rure = dontCheck super.regex-rure;
459 # https://hydra.nixos.org/build/174540882/nixlog/9
460 jacinda = dontCheck super.jacinda;
462 # Greater floating point error on x86_64-darwin (!) for some reason
463 # https://github.com/ekmett/ad/issues/113
464 ad = overrideCabal (drv: {
465 testFlags = drv.testFlags or [ ] ++ [