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 yesod-bin = addBuildDepend darwin.apple_sdk.frameworks.Cocoa super.yesod-bin;
144 yesod-core = super.yesod-core.overrideAttrs (drv: {
145 # Allow access to local networking when the Darwin sandbox is enabled, so yesod-core can
146 # run tests that access localhost.
147 __darwinAllowLocalNetworking = true;
152 darwin.apple_sdk.frameworks.AppKit
153 darwin.apple_sdk.frameworks.IOKit
154 darwin.apple_sdk.frameworks.CoreFoundation
156 (super.hidapi.override { systemd = null; });
158 hmatrix = addBuildDepend darwin.apple_sdk.frameworks.Accelerate super.hmatrix;
160 blas-hs = overrideCabal (drv: {
161 libraryFrameworkDepends = [
162 darwin.apple_sdk.frameworks.Accelerate
163 ] ++ (drv.libraryFrameworkDepends or []);
166 # Ensure the necessary frameworks are propagatedBuildInputs on darwin
167 OpenGLRaw = overrideCabal (drv: {
168 librarySystemDepends = [];
169 libraryHaskellDepends = drv.libraryHaskellDepends ++ [
170 darwin.apple_sdk.frameworks.OpenGL
173 frameworkPaths=($(for i in $nativeBuildInputs; do if [ -d "$i"/Library/Frameworks ]; then echo "-F$i/Library/Frameworks"; fi done))
174 frameworkPaths=$(IFS=, ; echo "''${frameworkPaths[@]}")
175 configureFlags+=$(if [ -n "$frameworkPaths" ]; then echo -n "--ghc-options=-optl=$frameworkPaths"; fi)
176 '' + (drv.preConfigure or "");
178 GLURaw = overrideCabal (drv: {
179 librarySystemDepends = [];
180 libraryHaskellDepends = drv.libraryHaskellDepends ++ [
181 darwin.apple_sdk.frameworks.OpenGL
184 bindings-GLFW = overrideCabal (drv: {
185 librarySystemDepends = [];
186 libraryHaskellDepends = drv.libraryHaskellDepends ++ [
187 darwin.apple_sdk.frameworks.AGL
188 darwin.apple_sdk.frameworks.Cocoa
189 darwin.apple_sdk.frameworks.OpenGL
190 darwin.apple_sdk.frameworks.IOKit
191 darwin.apple_sdk.frameworks.Kernel
192 darwin.apple_sdk.frameworks.CoreVideo
195 }) super.bindings-GLFW;
196 OpenCL = overrideCabal (drv: {
197 librarySystemDepends = [];
198 libraryHaskellDepends = drv.libraryHaskellDepends ++ [
199 darwin.apple_sdk.frameworks.OpenCL
203 # cabal2nix likes to generate dependencies on hinotify when hfsevents is
204 # really required on darwin: https://github.com/NixOS/cabal2nix/issues/146.
205 hinotify = self.hfsevents;
207 # FSEvents API is very buggy and tests are unreliable. See
208 # http://openradar.appspot.com/10207999 and similar issues.
209 fsnotify = addBuildDepend darwin.apple_sdk.frameworks.Cocoa
210 (dontCheck super.fsnotify);
212 FractalArt = overrideCabal (drv: {
213 librarySystemDepends = [
215 darwin.apple_sdk.frameworks.AppKit
216 ] ++ (drv.librarySystemDepends or []);
219 arbtt = overrideCabal (drv: {
220 librarySystemDepends = [
221 darwin.apple_sdk.frameworks.Foundation
222 darwin.apple_sdk.frameworks.Carbon
223 darwin.apple_sdk.frameworks.IOKit
224 ] ++ (drv.librarySystemDepends or []);
227 HTF = overrideCabal (drv: {
228 # GNU find is not prefixed in stdenv
230 substituteInPlace scripts/local-htfpp --replace "find=gfind" "find=find"
231 '' + (drv.postPatch or "");
234 # conditional dependency via a cabal flag
235 cas-store = overrideCabal (drv: {
236 libraryHaskellDepends = [
238 ] ++ (drv.libraryHaskellDepends or []);
241 # We are lacking pure pgrep at the moment for tests to work
242 tmp-postgres = dontCheck super.tmp-postgres;
244 # On darwin librt doesn't exist and will fail to link against,
245 # however linking against it is also not necessary there
246 GLHUI = overrideCabal (drv: {
248 substituteInPlace GLHUI.cabal --replace " rt" ""
249 '' + (drv.postPatch or "");
252 SDL-image = overrideCabal (drv: {
253 # Prevent darwin-specific configuration code path being taken
254 # which doesn't work with nixpkgs' SDL libraries
256 substituteInPlace configure --replace xDarwin noDarwinSpecialCasing
257 '' + (drv.postPatch or "");
259 # Work around SDL_main.h redefining main to SDL_main
260 ./patches/SDL-image-darwin-hsc.patch
264 # Prevent darwin-specific configuration code path being taken which
265 # doesn't work with nixpkgs' SDL libraries
266 SDL-mixer = overrideCabal (drv: {
268 substituteInPlace configure --replace xDarwin noDarwinSpecialCasing
269 '' + (drv.postPatch or "");
272 # Work around SDL_main.h redefining main to SDL_main
273 SDL-ttf = appendPatch ./patches/SDL-ttf-darwin-hsc.patch super.SDL-ttf;
275 # Disable a bunch of test suites that fail because of darwin's case insensitive
276 # file system: When a test suite has a test suite file that has the same name
277 # as a module in scope, but in different case (e. g. hedgehog.hs and Hedgehog
278 # in scope), GHC will complain that the file name and module name differ (in
279 # the example hedgehog.hs would be Main).
280 # These failures can easily be fixed by upstream by renaming files, so we
281 # should create issues for them.
282 # https://github.com/typeclasses/aws-cloudfront-signed-cookies/issues/2
283 aws-cloudfront-signed-cookies = dontCheck super.aws-cloudfront-signed-cookies;
285 # https://github.com/acid-state/acid-state/issues/133
286 acid-state = dontCheck super.acid-state;
288 # Otherwise impure gcc is used, which is Apple's weird wrapper
289 c2hsc = addTestToolDepends [ pkgs.gcc ] super.c2hsc;
291 http-client-tls = overrideCabal (drv: {
293 # This comment has been inserted, so the derivation hash changes, forcing
294 # a rebuild of this derivation which has succeeded to build on Hydra before,
295 # but apparently been corrupted, causing reverse dependencies to fail.
297 # This workaround can be removed upon the next darwin stdenv rebuild,
298 # presumably https://github.com/NixOS/nixpkgs/pull/152850 or the next
299 # full haskellPackages rebuild.
300 '' + drv.postPatch or "";
301 }) super.http-client-tls;
303 http2 = super.http2.overrideAttrs (drv: {
304 # Allow access to local networking when the Darwin sandbox is enabled, so http2 can run tests
305 # that access localhost.
306 __darwinAllowLocalNetworking = true;
309 # network requires `IP_RECVTOS`, which was added in 10.15.
311 if lib.versionOlder (lib.getVersion pkgs.apple-sdk) "10.15" then
312 addBuildDepend pkgs.apple-sdk_10_15 super.network
316 foldl = overrideCabal (drv: {
318 # This comment has been inserted, so the derivation hash changes, forcing
319 # a rebuild of this derivation which has succeeded to build on Hydra before,
320 # but apparently been corrupted, causing reverse dependencies to fail.
322 # This workaround can be removed upon the next darwin stdenv rebuild,
323 # presumably https://github.com/NixOS/nixpkgs/pull/152850 or the next
324 # full haskellPackages rebuild.
325 '' + drv.postPatch or "";
328 # https://hydra.nixos.org/build/230964714/nixlog/1
329 inline-c-cpp = appendPatch (pkgs.fetchpatch {
330 url = "https://github.com/fpco/inline-c/commit/e8dc553b13bb847409fdced649a6a863323cff8a.patch";
331 name = "revert-use-system-cxx-std-lib.patch";
332 sha256 = "sha256-ql1/+8bvmWexyCdFR0VS4M4cY2lD0Px/9dHYLqlKyNA=";
335 }) super.inline-c-cpp;
337 # Tests fail on macOS https://github.com/mrkkrp/zip/issues/112
338 zip = dontCheck super.zip;
340 snap = super.snap.overrideAttrs (drv: {
341 __darwinAllowLocalNetworking = true;
344 warp = super.warp.overrideAttrs (drv: {
345 __darwinAllowLocalNetworking = true;
348 ghcjs-dom-hello = overrideCabal (drv: {
349 libraryHaskellDepends = with self; [ jsaddle jsaddle-warp ];
350 executableHaskellDepends = with self; [ ghcjs-dom jsaddle-wkwebview ];
351 }) super.ghcjs-dom-hello;
353 jsaddle-hello = overrideCabal (drv: {
354 libraryHaskellDepends = with self; [ jsaddle lens ];
355 executableHaskellDepends = with self; [ jsaddle-warp jsaddle-wkwebview ];
356 }) super.jsaddle-hello;
358 jsaddle-wkwebview = overrideCabal (drv: {
359 libraryFrameworkDepends = with pkgs.buildPackages.darwin.apple_sdk.frameworks; [ Cocoa WebKit ];
360 libraryHaskellDepends = with self; [ aeson data-default jsaddle ]; # cabal2nix doesn't add darwin-only deps
361 }) super.jsaddle-wkwebview;
363 # cabal2nix doesn't add darwin-only deps
364 reflex-dom = addBuildDepend self.jsaddle-wkwebview (super.reflex-dom.override (drv: {
365 jsaddle-webkit2gtk = null;
368 # Remove a problematic assert, the length is sometimes 1 instead of 2 on darwin
369 di-core = overrideCabal (drv: {
371 substituteInPlace test/Main.hs --replace \
372 "2 @=? List.length (List.nub (List.sort (map Di.log_time logs)))" ""
376 } // lib.optionalAttrs pkgs.stdenv.hostPlatform.isAarch64 { # aarch64-darwin
378 # Workarounds for justStaticExecutables on aarch64-darwin. Since dead code
379 # elimination barely works on aarch64-darwin, any package that has a
380 # dependency that uses a Paths_ module will incur a reference on GHC, making
381 # it fail with disallowGhcReference (which is set by justStaticExecutables).
383 # To address this, you can either manually remove the references causing this
384 # after verifying they are indeed erroneous (e.g. cabal2nix) or just disable
385 # the check, sticking with the status quo. Ideally there'll be zero cases of
386 # the latter in the future!
388 lib.mapAttrs (_: overrideCabal (old: {
390 remove-references-to -t ${self.hpack} "$out/bin/cabal2nix"
391 # Note: The `data` output is needed at runtime.
392 remove-references-to -t ${self.distribution-nixpkgs.out} "$out/bin/hackage2nix"
394 ${old.postInstall or ""}
397 ) cabal2nix cabal2nix-unstable;
399 # https://github.com/fpco/unliftio/issues/87
400 unliftio = dontCheck super.unliftio;
401 # This is the same issue as above; the rio tests call functions in unliftio
402 # that have issues as tracked in the GitHub issue above. Once the unliftio
403 # tests are fixed, we can remove this as well.
405 # We skip just the problematic tests by replacing 'it' with 'xit'.
406 rio = overrideCabal (drv: {
408 sed -i 's/\bit /xit /g' test/RIO/FileSpec.hs
412 # https://github.com/haskell-crypto/cryptonite/issues/360
413 cryptonite = appendPatch ./patches/cryptonite-remove-argon2.patch super.cryptonite;
415 # Build segfaults unless `fixity-th` is disabled.
416 # https://github.com/tweag/ormolu/issues/927
417 ormolu = overrideCabal (drv: {
418 libraryHaskellDepends = drv.libraryHaskellDepends ++ [ self.file-embed ];
419 }) (disableCabalFlag "fixity-th" super.ormolu);
420 fourmolu = overrideCabal (drv: {
421 libraryHaskellDepends = drv.libraryHaskellDepends ++ [ self.file-embed ];
422 }) (disableCabalFlag "fixity-th" super.fourmolu);
424 # https://github.com/NixOS/nixpkgs/issues/149692
425 Agda = disableCabalFlag "optimise-heavily" super.Agda;
427 # https://github.com/NixOS/nixpkgs/issues/198495
428 eventsourcing-postgresql = dontCheck super.eventsourcing-postgresql;
429 gargoyle-postgresql-connect = dontCheck super.gargoyle-postgresql-connect;
430 hs-opentelemetry-instrumentation-postgresql-simple = dontCheck super.hs-opentelemetry-instrumentation-postgresql-simple;
431 moto-postgresql = dontCheck super.moto-postgresql;
432 persistent-postgresql = dontCheck super.persistent-postgresql;
433 pipes-postgresql-simple = dontCheck super.pipes-postgresql-simple;
434 postgresql-connector = dontCheck super.postgresql-connector;
435 postgresql-migration = dontCheck super.postgresql-migration;
436 postgresql-schema = dontCheck super.postgresql-schema;
437 postgresql-simple = dontCheck super.postgresql-simple;
438 postgresql-simple-interpolate = dontCheck super.postgresql-simple-interpolate;
439 postgresql-simple-migration = dontCheck super.postgresql-simple-migration;
440 postgresql-simple-url = dontCheck super.postgresql-simple-url;
441 postgresql-transactional = dontCheck super.postgresql-transactional;
442 postgrest = dontCheck super.postgrest;
443 rivet-adaptor-postgresql = dontCheck super.rivet-adaptor-postgresql;
444 tmp-proc-postgres = dontCheck super.tmp-proc-postgres;
446 } // lib.optionalAttrs pkgs.stdenv.hostPlatform.isx86_64 { # x86_64-darwin
448 # tests appear to be failing to link or something:
449 # https://hydra.nixos.org/build/174540882/nixlog/9
450 regex-rure = dontCheck super.regex-rure;
452 # https://hydra.nixos.org/build/174540882/nixlog/9
453 jacinda = dontCheck super.jacinda;
455 # Greater floating point error on x86_64-darwin (!) for some reason
456 # https://github.com/ekmett/ad/issues/113
457 ad = overrideCabal (drv: {
458 testFlags = drv.testFlags or [ ] ++ [