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 # the system-fileio tests use canonicalizePath, which fails in the sandbox
83 system-fileio = dontCheck super.system-fileio;
85 # Prevents needing to add `security_tool` as a run-time dependency for
86 # everything using x509-system to give access to the `security` executable.
88 # darwin.security_tool is broken in Mojave (#45042)
90 # We will use the system provided security for now.
91 # Beware this WILL break in sandboxes!
93 # TODO(matthewbauer): If someone really needs this to work in sandboxes,
94 # I think we can add a propagatedImpureHost dep here, but I’m hoping to
95 # get a proper fix available soonish.
96 x509-system = overrideCabal (drv:
97 lib.optionalAttrs (!pkgs.stdenv.cc.nativeLibc) {
99 substituteInPlace System/X509/MacOS.hs --replace security /usr/bin/security
100 '' + (drv.postPatch or "");
101 }) super.x509-system;
103 # https://github.com/haskell-foundation/foundation/pull/412
104 foundation = dontCheck super.foundation;
106 llvm-hs = overrideCabal (oldAttrs: {
107 # One test fails on darwin.
109 # llvm-hs's Setup.hs file tries to add the lib/ directory from LLVM8 to
110 # the DYLD_LIBRARY_PATH environment variable. This messes up clang
111 # when called from GHC, probably because clang is version 7, but we are
113 preCompileBuildDriver = ''
114 substituteInPlace Setup.hs --replace "addToLdLibraryPath libDir" "pure ()"
115 '' + (oldAttrs.preCompileBuildDriver or "");
118 yesod-bin = addBuildDepend darwin.apple_sdk.frameworks.Cocoa super.yesod-bin;
120 yesod-core = super.yesod-core.overrideAttrs (drv: {
121 # Allow access to local networking when the Darwin sandbox is enabled, so yesod-core can
122 # run tests that access localhost.
123 __darwinAllowLocalNetworking = true;
126 hmatrix = addBuildDepend darwin.apple_sdk.frameworks.Accelerate super.hmatrix;
128 blas-hs = overrideCabal (drv: {
129 libraryFrameworkDepends = [
130 darwin.apple_sdk.frameworks.Accelerate
131 ] ++ (drv.libraryFrameworkDepends or []);
134 # Ensure the necessary frameworks are propagatedBuildInputs on darwin
135 OpenGLRaw = overrideCabal (drv: {
136 librarySystemDepends = [];
137 libraryHaskellDepends = drv.libraryHaskellDepends ++ [
138 darwin.apple_sdk.frameworks.OpenGL
141 frameworkPaths=($(for i in $nativeBuildInputs; do if [ -d "$i"/Library/Frameworks ]; then echo "-F$i/Library/Frameworks"; fi done))
142 frameworkPaths=$(IFS=, ; echo "''${frameworkPaths[@]}")
143 configureFlags+=$(if [ -n "$frameworkPaths" ]; then echo -n "--ghc-options=-optl=$frameworkPaths"; fi)
144 '' + (drv.preConfigure or "");
146 GLURaw = overrideCabal (drv: {
147 librarySystemDepends = [];
148 libraryHaskellDepends = drv.libraryHaskellDepends ++ [
149 darwin.apple_sdk.frameworks.OpenGL
152 bindings-GLFW = overrideCabal (drv: {
153 librarySystemDepends = [];
154 libraryHaskellDepends = drv.libraryHaskellDepends ++ [
155 darwin.apple_sdk.frameworks.AGL
156 darwin.apple_sdk.frameworks.Cocoa
157 darwin.apple_sdk.frameworks.OpenGL
158 darwin.apple_sdk.frameworks.IOKit
159 darwin.apple_sdk.frameworks.Kernel
160 darwin.apple_sdk.frameworks.CoreVideo
163 }) super.bindings-GLFW;
164 OpenCL = overrideCabal (drv: {
165 librarySystemDepends = [];
166 libraryHaskellDepends = drv.libraryHaskellDepends ++ [
167 darwin.apple_sdk.frameworks.OpenCL
171 # cabal2nix likes to generate dependencies on hinotify when hfsevents is
172 # really required on darwin: https://github.com/NixOS/cabal2nix/issues/146.
173 hinotify = self.hfsevents;
175 # FSEvents API is very buggy and tests are unreliable. See
176 # http://openradar.appspot.com/10207999 and similar issues.
177 fsnotify = addBuildDepend darwin.apple_sdk.frameworks.Cocoa
178 (dontCheck super.fsnotify);
180 FractalArt = overrideCabal (drv: {
181 librarySystemDepends = [
183 darwin.apple_sdk.frameworks.AppKit
184 ] ++ (drv.librarySystemDepends or []);
187 arbtt = overrideCabal (drv: {
188 librarySystemDepends = [
189 darwin.apple_sdk.frameworks.Foundation
190 darwin.apple_sdk.frameworks.Carbon
191 darwin.apple_sdk.frameworks.IOKit
192 ] ++ (drv.librarySystemDepends or []);
195 HTF = overrideCabal (drv: {
196 # GNU find is not prefixed in stdenv
198 substituteInPlace scripts/local-htfpp --replace "find=gfind" "find=find"
199 '' + (drv.postPatch or "");
202 # conditional dependency via a cabal flag
203 cas-store = overrideCabal (drv: {
204 libraryHaskellDepends = [
206 ] ++ (drv.libraryHaskellDepends or []);
209 # 2021-05-25: Tests fail and I have no way to debug them.
210 hls-class-plugin = dontCheck super.hls-class-plugin;
211 hls-brittany-plugin = dontCheck super.hls-brittany-plugin;
212 hls-fourmolu-plugin = dontCheck super.hls-fourmolu-plugin;
213 hls-module-name-plugin = dontCheck super.hls-module-name-plugin;
214 hls-splice-plugin = dontCheck super.hls-splice-plugin;
215 hls-ormolu-plugin = dontCheck super.hls-ormolu-plugin;
216 hls-pragmas-plugin = dontCheck super.hls-pragmas-plugin;
217 hls-haddock-comments-plugin = dontCheck super.hls-haddock-comments-plugin;
218 hls-floskell-plugin = dontCheck super.hls-floskell-plugin;
219 hls-call-hierarchy-plugin = dontCheck super.hls-call-hierarchy-plugin;
220 # 2022-05-05: Tests fail and I have no way to debug them.
221 hls-rename-plugin = dontCheck super.hls-rename-plugin;
223 # We are lacking pure pgrep at the moment for tests to work
224 tmp-postgres = dontCheck super.tmp-postgres;
226 # On darwin librt doesn't exist and will fail to link against,
227 # however linking against it is also not necessary there
228 GLHUI = overrideCabal (drv: {
230 substituteInPlace GLHUI.cabal --replace " rt" ""
231 '' + (drv.postPatch or "");
234 SDL-image = overrideCabal (drv: {
235 # Prevent darwin-specific configuration code path being taken
236 # which doesn't work with nixpkgs' SDL libraries
238 substituteInPlace configure --replace xDarwin noDarwinSpecialCasing
239 '' + (drv.postPatch or "");
241 # Work around SDL_main.h redefining main to SDL_main
242 ./patches/SDL-image-darwin-hsc.patch
246 # Prevent darwin-specific configuration code path being taken which
247 # doesn't work with nixpkgs' SDL libraries
248 SDL-mixer = overrideCabal (drv: {
250 substituteInPlace configure --replace xDarwin noDarwinSpecialCasing
251 '' + (drv.postPatch or "");
254 # Work around SDL_main.h redefining main to SDL_main
255 SDL-ttf = appendPatch ./patches/SDL-ttf-darwin-hsc.patch super.SDL-ttf;
257 # Disable a bunch of test suites that fail because of darwin's case insensitive
258 # file system: When a test suite has a test suite file that has the same name
259 # as a module in scope, but in different case (e. g. hedgehog.hs and Hedgehog
260 # in scope), GHC will complain that the file name and module name differ (in
261 # the example hedgehog.hs would be Main).
262 # These failures can easily be fixed by upstream by renaming files, so we
263 # should create issues for them.
264 # https://github.com/typeclasses/aws-cloudfront-signed-cookies/issues/2
265 aws-cloudfront-signed-cookies = dontCheck super.aws-cloudfront-signed-cookies;
267 # https://github.com/acid-state/acid-state/issues/133
268 acid-state = dontCheck super.acid-state;
270 # Otherwise impure gcc is used, which is Apple's weird wrapper
271 c2hsc = addTestToolDepends [ pkgs.gcc ] super.c2hsc;
273 http-client-tls = overrideCabal (drv: {
275 # This comment has been inserted, so the derivation hash changes, forcing
276 # a rebuild of this derivation which has succeeded to build on Hydra before,
277 # but apparently been corrupted, causing reverse dependencies to fail.
279 # This workaround can be removed upon the next darwin stdenv rebuild,
280 # presumably https://github.com/NixOS/nixpkgs/pull/152850 or the next
281 # full haskellPackages rebuild.
282 '' + drv.postPatch or "";
283 }) super.http-client-tls;
285 http2 = super.http2.overrideAttrs (drv: {
286 # Allow access to local networking when the Darwin sandbox is enabled, so http2 can run tests
287 # that access localhost.
288 __darwinAllowLocalNetworking = true;
291 foldl = 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 "";
303 # https://hydra.nixos.org/build/230964714/nixlog/1
304 inline-c-cpp = appendPatch (pkgs.fetchpatch {
305 url = "https://github.com/fpco/inline-c/commit/e8dc553b13bb847409fdced649a6a863323cff8a.patch";
306 name = "revert-use-system-cxx-std-lib.patch";
307 sha256 = "sha256-ql1/+8bvmWexyCdFR0VS4M4cY2lD0Px/9dHYLqlKyNA=";
310 }) super.inline-c-cpp;
312 } // lib.optionalAttrs pkgs.stdenv.isAarch64 { # aarch64-darwin
314 # https://github.com/fpco/unliftio/issues/87
315 unliftio = dontCheck super.unliftio;
316 # This is the same issue as above; the rio tests call functions in unliftio
317 # that have issues as tracked in the GitHub issue above. Once the unliftio
318 # tests are fixed, we can remove this as well.
320 # We skip just the problematic tests by replacing 'it' with 'xit'.
321 rio = overrideCabal (drv: {
323 sed -i 's/\bit /xit /g' test/RIO/FileSpec.hs
327 # https://github.com/haskell-crypto/cryptonite/issues/360
328 cryptonite = appendPatch ./patches/cryptonite-remove-argon2.patch super.cryptonite;
330 # Build segfaults unless `fixity-th` is disabled.
331 # https://github.com/tweag/ormolu/issues/927
332 ormolu = overrideCabal (drv: {
333 libraryHaskellDepends = drv.libraryHaskellDepends ++ [ self.file-embed ];
334 }) (disableCabalFlag "fixity-th" super.ormolu);
335 fourmolu = overrideCabal (drv: {
336 libraryHaskellDepends = drv.libraryHaskellDepends ++ [ self.file-embed ];
337 }) (disableCabalFlag "fixity-th" super.fourmolu);
339 # https://github.com/NixOS/nixpkgs/issues/149692
340 Agda = removeConfigureFlag "-foptimise-heavily" super.Agda;
342 } // lib.optionalAttrs pkgs.stdenv.isx86_64 { # x86_64-darwin
344 # tests appear to be failing to link or something:
345 # https://hydra.nixos.org/build/174540882/nixlog/9
346 regex-rure = dontCheck super.regex-rure;
348 # https://hydra.nixos.org/build/174540882/nixlog/9
349 jacinda = dontCheck super.jacinda;