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