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 # Prevents needing to add `security_tool` as a run-time dependency for
98 # everything using x509-system to give access to the `security` executable.
100 # darwin.security_tool is broken in Mojave (#45042)
102 # We will use the system provided security for now.
103 # Beware this WILL break in sandboxes!
105 # TODO(matthewbauer): If someone really needs this to work in sandboxes,
106 # I think we can add a propagatedImpureHost dep here, but I’m hoping to
107 # get a proper fix available soonish.
108 x509-system = overrideCabal (drv:
109 lib.optionalAttrs (!pkgs.stdenv.cc.nativeLibc) {
111 substituteInPlace System/X509/MacOS.hs --replace security /usr/bin/security
112 '' + (drv.postPatch or "");
113 }) super.x509-system;
114 crypton-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.crypton-x509-system;
121 # https://github.com/haskell-foundation/foundation/pull/412
122 foundation = dontCheck super.foundation;
124 llvm-hs = overrideCabal (oldAttrs: {
125 # One test fails on darwin.
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
131 preCompileBuildDriver = ''
132 substituteInPlace Setup.hs --replace "addToLdLibraryPath libDir" "pure ()"
133 '' + (oldAttrs.preCompileBuildDriver or "");
136 yesod-bin = addBuildDepend darwin.apple_sdk.frameworks.Cocoa super.yesod-bin;
138 yesod-core = super.yesod-core.overrideAttrs (drv: {
139 # Allow access to local networking when the Darwin sandbox is enabled, so yesod-core can
140 # run tests that access localhost.
141 __darwinAllowLocalNetworking = true;
146 darwin.apple_sdk.frameworks.AppKit
147 darwin.apple_sdk.frameworks.IOKit
148 darwin.apple_sdk.frameworks.CoreFoundation
150 (super.hidapi.override { systemd = null; });
152 hmatrix = addBuildDepend darwin.apple_sdk.frameworks.Accelerate super.hmatrix;
154 blas-hs = overrideCabal (drv: {
155 libraryFrameworkDepends = [
156 darwin.apple_sdk.frameworks.Accelerate
157 ] ++ (drv.libraryFrameworkDepends or []);
160 # Ensure the necessary frameworks are propagatedBuildInputs on darwin
161 OpenGLRaw = overrideCabal (drv: {
162 librarySystemDepends = [];
163 libraryHaskellDepends = drv.libraryHaskellDepends ++ [
164 darwin.apple_sdk.frameworks.OpenGL
167 frameworkPaths=($(for i in $nativeBuildInputs; do if [ -d "$i"/Library/Frameworks ]; then echo "-F$i/Library/Frameworks"; fi done))
168 frameworkPaths=$(IFS=, ; echo "''${frameworkPaths[@]}")
169 configureFlags+=$(if [ -n "$frameworkPaths" ]; then echo -n "--ghc-options=-optl=$frameworkPaths"; fi)
170 '' + (drv.preConfigure or "");
172 GLURaw = overrideCabal (drv: {
173 librarySystemDepends = [];
174 libraryHaskellDepends = drv.libraryHaskellDepends ++ [
175 darwin.apple_sdk.frameworks.OpenGL
178 bindings-GLFW = overrideCabal (drv: {
179 librarySystemDepends = [];
180 libraryHaskellDepends = drv.libraryHaskellDepends ++ [
181 darwin.apple_sdk.frameworks.AGL
182 darwin.apple_sdk.frameworks.Cocoa
183 darwin.apple_sdk.frameworks.OpenGL
184 darwin.apple_sdk.frameworks.IOKit
185 darwin.apple_sdk.frameworks.Kernel
186 darwin.apple_sdk.frameworks.CoreVideo
189 }) super.bindings-GLFW;
190 OpenCL = overrideCabal (drv: {
191 librarySystemDepends = [];
192 libraryHaskellDepends = drv.libraryHaskellDepends ++ [
193 darwin.apple_sdk.frameworks.OpenCL
197 # cabal2nix likes to generate dependencies on hinotify when hfsevents is
198 # really required on darwin: https://github.com/NixOS/cabal2nix/issues/146.
199 hinotify = self.hfsevents;
201 # FSEvents API is very buggy and tests are unreliable. See
202 # http://openradar.appspot.com/10207999 and similar issues.
203 fsnotify = addBuildDepend darwin.apple_sdk.frameworks.Cocoa
204 (dontCheck super.fsnotify);
206 FractalArt = overrideCabal (drv: {
207 librarySystemDepends = [
209 darwin.apple_sdk.frameworks.AppKit
210 ] ++ (drv.librarySystemDepends or []);
213 arbtt = overrideCabal (drv: {
214 librarySystemDepends = [
215 darwin.apple_sdk.frameworks.Foundation
216 darwin.apple_sdk.frameworks.Carbon
217 darwin.apple_sdk.frameworks.IOKit
218 ] ++ (drv.librarySystemDepends or []);
221 HTF = overrideCabal (drv: {
222 # GNU find is not prefixed in stdenv
224 substituteInPlace scripts/local-htfpp --replace "find=gfind" "find=find"
225 '' + (drv.postPatch or "");
228 # conditional dependency via a cabal flag
229 cas-store = overrideCabal (drv: {
230 libraryHaskellDepends = [
232 ] ++ (drv.libraryHaskellDepends or []);
235 # We are lacking pure pgrep at the moment for tests to work
236 tmp-postgres = dontCheck super.tmp-postgres;
238 # On darwin librt doesn't exist and will fail to link against,
239 # however linking against it is also not necessary there
240 GLHUI = overrideCabal (drv: {
242 substituteInPlace GLHUI.cabal --replace " rt" ""
243 '' + (drv.postPatch or "");
246 SDL-image = overrideCabal (drv: {
247 # Prevent darwin-specific configuration code path being taken
248 # which doesn't work with nixpkgs' SDL libraries
250 substituteInPlace configure --replace xDarwin noDarwinSpecialCasing
251 '' + (drv.postPatch or "");
253 # Work around SDL_main.h redefining main to SDL_main
254 ./patches/SDL-image-darwin-hsc.patch
258 # Prevent darwin-specific configuration code path being taken which
259 # doesn't work with nixpkgs' SDL libraries
260 SDL-mixer = overrideCabal (drv: {
262 substituteInPlace configure --replace xDarwin noDarwinSpecialCasing
263 '' + (drv.postPatch or "");
266 # Work around SDL_main.h redefining main to SDL_main
267 SDL-ttf = appendPatch ./patches/SDL-ttf-darwin-hsc.patch super.SDL-ttf;
269 # Disable a bunch of test suites that fail because of darwin's case insensitive
270 # file system: When a test suite has a test suite file that has the same name
271 # as a module in scope, but in different case (e. g. hedgehog.hs and Hedgehog
272 # in scope), GHC will complain that the file name and module name differ (in
273 # the example hedgehog.hs would be Main).
274 # These failures can easily be fixed by upstream by renaming files, so we
275 # should create issues for them.
276 # https://github.com/typeclasses/aws-cloudfront-signed-cookies/issues/2
277 aws-cloudfront-signed-cookies = dontCheck super.aws-cloudfront-signed-cookies;
279 # https://github.com/acid-state/acid-state/issues/133
280 acid-state = dontCheck super.acid-state;
282 # Otherwise impure gcc is used, which is Apple's weird wrapper
283 c2hsc = addTestToolDepends [ pkgs.gcc ] super.c2hsc;
285 http-client-tls = overrideCabal (drv: {
287 # This comment has been inserted, so the derivation hash changes, forcing
288 # a rebuild of this derivation which has succeeded to build on Hydra before,
289 # but apparently been corrupted, causing reverse dependencies to fail.
291 # This workaround can be removed upon the next darwin stdenv rebuild,
292 # presumably https://github.com/NixOS/nixpkgs/pull/152850 or the next
293 # full haskellPackages rebuild.
294 '' + drv.postPatch or "";
295 }) super.http-client-tls;
297 http2 = super.http2.overrideAttrs (drv: {
298 # Allow access to local networking when the Darwin sandbox is enabled, so http2 can run tests
299 # that access localhost.
300 __darwinAllowLocalNetworking = true;
303 foldl = overrideCabal (drv: {
305 # This comment has been inserted, so the derivation hash changes, forcing
306 # a rebuild of this derivation which has succeeded to build on Hydra before,
307 # but apparently been corrupted, causing reverse dependencies to fail.
309 # This workaround can be removed upon the next darwin stdenv rebuild,
310 # presumably https://github.com/NixOS/nixpkgs/pull/152850 or the next
311 # full haskellPackages rebuild.
312 '' + drv.postPatch or "";
315 # https://hydra.nixos.org/build/230964714/nixlog/1
316 inline-c-cpp = appendPatch (pkgs.fetchpatch {
317 url = "https://github.com/fpco/inline-c/commit/e8dc553b13bb847409fdced649a6a863323cff8a.patch";
318 name = "revert-use-system-cxx-std-lib.patch";
319 sha256 = "sha256-ql1/+8bvmWexyCdFR0VS4M4cY2lD0Px/9dHYLqlKyNA=";
322 }) super.inline-c-cpp;
324 # Tests fail on macOS https://github.com/mrkkrp/zip/issues/112
325 zip = dontCheck super.zip;
327 warp = super.warp.overrideAttrs (drv: {
328 __darwinAllowLocalNetworking = true;
331 ghcjs-dom-hello = overrideCabal (drv: {
332 libraryHaskellDepends = with self; [ jsaddle jsaddle-warp ];
333 executableHaskellDepends = with self; [ ghcjs-dom jsaddle-wkwebview ];
334 }) super.ghcjs-dom-hello;
336 jsaddle-hello = overrideCabal (drv: {
337 libraryHaskellDepends = with self; [ jsaddle lens ];
338 executableHaskellDepends = with self; [ jsaddle-warp jsaddle-wkwebview ];
339 }) super.jsaddle-hello;
341 jsaddle-wkwebview = overrideCabal (drv: {
342 libraryFrameworkDepends = with pkgs.buildPackages.darwin.apple_sdk.frameworks; [ Cocoa WebKit ];
343 libraryHaskellDepends = with self; [ aeson data-default jsaddle ]; # cabal2nix doesn't add darwin-only deps
344 }) super.jsaddle-wkwebview;
346 # cabal2nix doesn't add darwin-only deps
347 reflex-dom = addBuildDepend self.jsaddle-wkwebview (super.reflex-dom.override (drv: {
348 jsaddle-webkit2gtk = null;
351 # Remove a problematic assert, the length is sometimes 1 instead of 2 on darwin
352 di-core = overrideCabal (drv: {
354 substituteInPlace test/Main.hs --replace \
355 "2 @=? List.length (List.nub (List.sort (map Di.log_time logs)))" ""
359 } // lib.optionalAttrs pkgs.stdenv.hostPlatform.isAarch64 { # aarch64-darwin
361 # Workarounds for justStaticExecutables on aarch64-darwin. Since dead code
362 # elimination barely works on aarch64-darwin, any package that has a
363 # dependency that uses a Paths_ module will incur a reference on GHC, making
364 # it fail with disallowGhcReference (which is set by justStaticExecutables).
366 # To address this, you can either manually remove the references causing this
367 # after verifying they are indeed erroneous (e.g. cabal2nix) or just disable
368 # the check, sticking with the status quo. Ideally there'll be zero cases of
369 # the latter in the future!
371 lib.mapAttrs (_: overrideCabal (old: {
373 remove-references-to -t ${self.hpack} "$out/bin/cabal2nix"
374 # Note: The `data` output is needed at runtime.
375 remove-references-to -t ${self.distribution-nixpkgs.out} "$out/bin/hackage2nix"
377 ${old.postInstall or ""}
380 ) cabal2nix cabal2nix-unstable;
382 # https://github.com/fpco/unliftio/issues/87
383 unliftio = dontCheck super.unliftio;
384 # This is the same issue as above; the rio tests call functions in unliftio
385 # that have issues as tracked in the GitHub issue above. Once the unliftio
386 # tests are fixed, we can remove this as well.
388 # We skip just the problematic tests by replacing 'it' with 'xit'.
389 rio = overrideCabal (drv: {
391 sed -i 's/\bit /xit /g' test/RIO/FileSpec.hs
395 # https://github.com/haskell-crypto/cryptonite/issues/360
396 cryptonite = appendPatch ./patches/cryptonite-remove-argon2.patch super.cryptonite;
398 # Build segfaults unless `fixity-th` is disabled.
399 # https://github.com/tweag/ormolu/issues/927
400 ormolu = overrideCabal (drv: {
401 libraryHaskellDepends = drv.libraryHaskellDepends ++ [ self.file-embed ];
402 }) (disableCabalFlag "fixity-th" super.ormolu);
403 fourmolu = overrideCabal (drv: {
404 libraryHaskellDepends = drv.libraryHaskellDepends ++ [ self.file-embed ];
405 }) (disableCabalFlag "fixity-th" super.fourmolu);
407 # https://github.com/NixOS/nixpkgs/issues/149692
408 Agda = disableCabalFlag "optimise-heavily" super.Agda;
410 # https://github.com/NixOS/nixpkgs/issues/198495
411 eventsourcing-postgresql = dontCheck super.eventsourcing-postgresql;
412 gargoyle-postgresql-connect = dontCheck super.gargoyle-postgresql-connect;
413 hs-opentelemetry-instrumentation-postgresql-simple = dontCheck super.hs-opentelemetry-instrumentation-postgresql-simple;
414 moto-postgresql = dontCheck super.moto-postgresql;
415 persistent-postgresql = dontCheck super.persistent-postgresql;
416 pipes-postgresql-simple = dontCheck super.pipes-postgresql-simple;
417 postgresql-connector = dontCheck super.postgresql-connector;
418 postgresql-migration = dontCheck super.postgresql-migration;
419 postgresql-schema = dontCheck super.postgresql-schema;
420 postgresql-simple = dontCheck super.postgresql-simple;
421 postgresql-simple-interpolate = dontCheck super.postgresql-simple-interpolate;
422 postgresql-simple-migration = dontCheck super.postgresql-simple-migration;
423 postgresql-simple-url = dontCheck super.postgresql-simple-url;
424 postgresql-transactional = dontCheck super.postgresql-transactional;
425 postgrest = dontCheck super.postgrest;
426 rivet-adaptor-postgresql = dontCheck super.rivet-adaptor-postgresql;
427 tmp-proc-postgres = dontCheck super.tmp-proc-postgres;
429 } // lib.optionalAttrs pkgs.stdenv.hostPlatform.isx86_64 { # x86_64-darwin
431 # tests appear to be failing to link or something:
432 # https://hydra.nixos.org/build/174540882/nixlog/9
433 regex-rure = dontCheck super.regex-rure;
435 # https://hydra.nixos.org/build/174540882/nixlog/9
436 jacinda = dontCheck super.jacinda;
438 # Greater floating point error on x86_64-darwin (!) for some reason
439 # https://github.com/ekmett/ad/issues/113
440 ad = overrideCabal (drv: {
441 testFlags = drv.testFlags or [ ] ++ [