From 312d3bf74b2c76bb3c20a2a00bc4f0abfd014938 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Sat, 8 May 2021 17:32:54 +0200 Subject: [PATCH] haskell.packages: move darwin-specific overrides into their own config --- .../haskell-modules/configuration-common.nix | 47 +---- .../haskell-modules/configuration-darwin.nix | 164 ++++++++++++++++++ .../haskell-modules/configuration-nix.nix | 135 +------------- pkgs/development/haskell-modules/default.nix | 3 + 4 files changed, 173 insertions(+), 176 deletions(-) create mode 100644 pkgs/development/haskell-modules/configuration-darwin.nix diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix index 9c60be7d64e..53c2097b060 100644 --- a/pkgs/development/haskell-modules/configuration-common.nix +++ b/pkgs/development/haskell-modules/configuration-common.nix @@ -75,10 +75,6 @@ self: super: { # Fix test trying to access /home directory shell-conduit = overrideCabal super.shell-conduit (drv: { postPatch = "sed -i s/home/tmp/ test/Spec.hs"; - - # the tests for shell-conduit on Darwin illegitimatey assume non-GNU echo - # see: https://github.com/psibi/shell-conduit/issues/12 - doCheck = !pkgs.stdenv.isDarwin; }); # https://github.com/froozen/kademlia/issues/2 @@ -117,15 +113,6 @@ self: super: { # Jailbreak is necessary for QuickCheck dependency. vector = doJailbreak (if pkgs.stdenv.isi686 then appendConfigureFlag super.vector "--ghc-options=-msse2" else super.vector); - conduit-extra = if pkgs.stdenv.isDarwin - then super.conduit-extra.overrideAttrs (drv: { __darwinAllowLocalNetworking = true; }) - else super.conduit-extra; - - # Fix Darwin build. - halive = if pkgs.stdenv.isDarwin - then addBuildDepend super.halive pkgs.darwin.apple_sdk.frameworks.AppKit - else super.halive; - # Test suite fails due golden tests checking text representation # of normalized dhall expressions, and newer dhall versions format # differently. @@ -134,19 +121,6 @@ self: super: { then throw "Drop dontCheck override for hpack-dhall > 0.5.2" else dontCheck super.hpack-dhall; - barbly = addBuildDepend super.barbly pkgs.darwin.apple_sdk.frameworks.AppKit; - - # Hakyll's tests are broken on Darwin (3 failures); and they require util-linux - hakyll = if pkgs.stdenv.isDarwin - then dontCheck (overrideCabal super.hakyll (drv: { - testToolDepends = []; - })) - else super.hakyll; - - double-conversion = if !pkgs.stdenv.isDarwin - then super.double-conversion - else addExtraLibrary super.double-conversion pkgs.libcxx; - inline-c-cpp = overrideCabal super.inline-c-cpp (drv: { postPatch = (drv.postPatch or "") + '' substituteInPlace inline-c-cpp.cabal --replace "-optc-std=c++11" "" @@ -311,18 +285,12 @@ self: super: { ldap-client = dontCheck super.ldap-client; lensref = dontCheck super.lensref; lvmrun = disableHardening (dontCheck super.lvmrun) ["format"]; - math-functions = if pkgs.stdenv.isDarwin - then dontCheck super.math-functions # "erf table" test fails on Darwin https://github.com/bos/math-functions/issues/63 - else super.math-functions; matplotlib = dontCheck super.matplotlib; # https://github.com/matterhorn-chat/matterhorn/issues/679 they do not want to be on stackage matterhorn = doJailbreak super.matterhorn; # this is needed until the end of time :') memcache = dontCheck super.memcache; metrics = dontCheck super.metrics; milena = dontCheck super.milena; - mockery = if pkgs.stdenv.isDarwin - then overrideCabal super.mockery (drv: { preCheck = "export TRAVIS=true"; }) # darwin doesn't have sub-second resolution https://github.com/hspec/mockery/issues/11 - else super.mockery; modular-arithmetic = dontCheck super.modular-arithmetic; # tests require a very old Glob (0.7.*) nats-queue = dontCheck super.nats-queue; netpbm = dontCheck super.netpbm; @@ -463,9 +431,8 @@ self: super: { # https://github.com/andrewthad/haskell-ip/issues/67 ip = dontCheck super.ip; - # https://github.com/ndmitchell/shake/issues/206 - # https://github.com/ndmitchell/shake/issues/267 - shake = overrideCabal super.shake (drv: { doCheck = !pkgs.stdenv.isDarwin && false; }); + # https://github.com/ndmitchell/shake/issues/804 + shake = dontCheck super.shake; # https://github.com/nushio3/doctest-prop/issues/1 doctest-prop = dontCheck super.doctest-prop; @@ -840,7 +807,6 @@ self: super: { # With ghc-8.2.x haddock would time out for unknown reason # See https://github.com/haskell/haddock/issues/679 language-puppet = dontHaddock super.language-puppet; - filecache = overrideCabal super.filecache (drv: { doCheck = !pkgs.stdenv.isDarwin; }); # https://github.com/alphaHeavy/protobuf/issues/34 protobuf = dontCheck super.protobuf; @@ -1155,11 +1121,6 @@ self: super: { ''; }); - # gtk/gtk3 needs to be told on Darwin to use the Quartz - # rather than X11 backend (see eg https://github.com/gtk2hs/gtk2hs/issues/249). - gtk3 = appendConfigureFlags super.gtk3 (pkgs.lib.optional pkgs.stdenv.isDarwin "-f have-quartz-gtk"); - gtk = appendConfigureFlags super.gtk (pkgs.lib.optional pkgs.stdenv.isDarwin "-f have-quartz-gtk"); - # Chart-tests needs and compiles some modules from Chart itself Chart-tests = (addExtraLibrary super.Chart-tests self.QuickCheck).overrideAttrs (old: { preCheck = old.postPatch or "" + '' @@ -1572,10 +1533,6 @@ self: super: { # https://github.com/yesodweb/yesod/issues/1714 yesod-core = dontCheck super.yesod-core; - # Add ApplicationServices on darwin - apecs-physics = addPkgconfigDepends super.apecs-physics - (pkgs.lib.optional pkgs.stdenv.isDarwin pkgs.darwin.apple_sdk.frameworks.ApplicationServices); - # Break out of overspecified constraint on QuickCheck. algebraic-graphs = dontCheck super.algebraic-graphs; attoparsec = doJailbreak super.attoparsec; # https://github.com/haskell/attoparsec/pull/168 diff --git a/pkgs/development/haskell-modules/configuration-darwin.nix b/pkgs/development/haskell-modules/configuration-darwin.nix new file mode 100644 index 00000000000..6768bc5d6b4 --- /dev/null +++ b/pkgs/development/haskell-modules/configuration-darwin.nix @@ -0,0 +1,164 @@ +# DARWIN-SPECIFIC OVERRIDES FOR THE HASKELL PACKAGE SET IN NIXPKGS + +{ pkgs, haskellLib }: + +let + inherit (pkgs) lib darwin; +in + +with haskellLib; + +self: super: { + + # the tests for shell-conduit on Darwin illegitimatey assume non-GNU echo + # see: https://github.com/psibi/shell-conduit/issues/12 + shell-conduit = dontCheck super.shell-conduit; + + conduit-extra = super.conduit-extra.overrideAttrs (drv: { + __darwinAllowLocalNetworking = true; + }); + + halive = addBuildDepend super.halive darwin.apple_sdk.frameworks.AppKit; + + # Hakyll's tests are broken on Darwin (3 failures); and they require util-linux + hakyll = overrideCabal super.hakyll { + testToolDepends = []; + doCheck = false; + }; + + barbly = addBuildDepend super.barbly darwin.apple_sdk.frameworks.AppKit; + + double-conversion = addExtraLibrary super.double-conversion pkgs.libcxx; + + apecs-physics = addPkgconfigDepends super.apecs-physics [ + darwin.apple_sdk.frameworks.ApplicationServices + ]; + + # "erf table" test fails on Darwin + # https://github.com/bos/math-functions/issues/63 + math-functions = dontCheck super.math-functions; + + # darwin doesn't have sub-second resolution + # https://github.com/hspec/mockery/issues/11 + mockery = overrideCabal super.mockery (drv: { + preCheck = '' + export TRAVIS=true + '' + (drv.preCheck or ""); + }); + + # https://github.com/ndmitchell/shake/issues/206 + shake = dontCheck super.shake; + + filecache = dontCheck super.filecache; + + # gtk/gtk3 needs to be told on Darwin to use the Quartz + # rather than X11 backend (see eg https://github.com/gtk2hs/gtk2hs/issues/249). + gtk3 = appendConfigureFlag super.gtk3 "-f have-quartz-gtk"; + gtk = appendConfigureFlag super.gtk "-f have-quartz-gtk"; + + OpenAL = addExtraLibrary super.OpenAL darwin.apple_sdk.frameworks.OpenAL; + + proteaaudio = addExtraLibrary super.proteaaudio darwin.apple_sdk.frameworks.AudioToolbox; + + # the system-fileio tests use canonicalizePath, which fails in the sandbox + system-fileio = dontCheck super.system-fileio; + + # Prevents needing to add `security_tool` as a run-time dependency for + # everything using x509-system to give access to the `security` executable. + # + # darwin.security_tool is broken in Mojave (#45042) + # + # We will use the system provided security for now. + # Beware this WILL break in sandboxes! + # + # TODO(matthewbauer): If someone really needs this to work in sandboxes, + # I think we can add a propagatedImpureHost dep here, but I’m hoping to + # get a proper fix available soonish. + x509-system = overrideCabal super.x509-system (drv: + lib.optionalAttrs (!pkgs.stdenv.cc.nativeLibc) { + postPatch = '' + substituteInPlace System/X509/MacOS.hs --replace security /usr/bin/security + '' + (drv.postPatch or ""); + }); + + # https://github.com/haskell-foundation/foundation/pull/412 + foundation = dontCheck super.foundation; + + llvm-hs = overrideCabal super.llvm-hs (oldAttrs: { + # One test fails on darwin. + doCheck = false; + # llvm-hs's Setup.hs file tries to add the lib/ directory from LLVM8 to + # the DYLD_LIBRARY_PATH environment variable. This messes up clang + # when called from GHC, probably because clang is version 7, but we are + # using LLVM8. + preCompileBuildDriver = '' + substituteInPlace Setup.hs --replace "addToLdLibraryPath libDir" "pure ()" + '' + (oldAttrs.preCompileBuildDriver or ""); + }); + + yesod-bin = addBuildDepend super.yesod-bin darwin.apple_sdk.frameworks.Cocoa; + + hmatrix = addBuildDepend super.hmatrix darwin.apple_sdk.frameworks.Accelerate; + + # Ensure the necessary frameworks are propagatedBuildInputs on darwin + OpenGLRaw = overrideCabal super.OpenGLRaw (drv: { + librarySystemDepends = []; + libraryHaskellDepends = drv.libraryHaskellDepends ++ [ + darwin.apple_sdk.frameworks.OpenGL + ]; + preConfigure = '' + frameworkPaths=($(for i in $nativeBuildInputs; do if [ -d "$i"/Library/Frameworks ]; then echo "-F$i/Library/Frameworks"; fi done)) + frameworkPaths=$(IFS=, ; echo "''${frameworkPaths[@]}") + configureFlags+=$(if [ -n "$frameworkPaths" ]; then echo -n "--ghc-options=-optl=$frameworkPaths"; fi) + '' + (drv.preConfigure or ""); + }); + GLURaw = overrideCabal super.GLURaw (drv: { + librarySystemDepends = []; + libraryHaskellDepends = drv.libraryHaskellDepends ++ [ + darwin.apple_sdk.frameworks.OpenGL + ]; + }); + bindings-GLFW = overrideCabal super.bindings-GLFW (drv: { + librarySystemDepends = []; + libraryHaskellDepends = drv.libraryHaskellDepends ++ [ + darwin.apple_sdk.frameworks.AGL + darwin.apple_sdk.frameworks.Cocoa + darwin.apple_sdk.frameworks.OpenGL + darwin.apple_sdk.frameworks.IOKit + darwin.apple_sdk.frameworks.Kernel + darwin.apple_sdk.frameworks.CoreVideo + darwin.CF + ]; + }); + OpenCL = overrideCabal super.OpenCL (drv: { + librarySystemDepends = []; + libraryHaskellDepends = drv.libraryHaskellDepends ++ [ + darwin.apple_sdk.frameworks.OpenCL + ]; + }); + + # cabal2nix likes to generate dependencies on hinotify when hfsevents is + # really required on darwin: https://github.com/NixOS/cabal2nix/issues/146. + hinotify = self.hfsevents; + + # FSEvents API is very buggy and tests are unreliable. See + # http://openradar.appspot.com/10207999 and similar issues. + fsnotify = addBuildDepend (dontCheck super.fsnotify) + darwin.apple_sdk.frameworks.Cocoa; + + FractalArt = overrideCabal super.FractalArt (drv: { + librarySystemDepends = [ + darwin.libobjc + darwin.apple_sdk.frameworks.AppKit + ] ++ (drv.librarySystemDepends or []); + }); + + arbtt = overrideCabal super.arbtt (drv: { + librarySystemDepends = [ + darwin.apple_sdk.frameworks.Foundation + darwin.apple_sdk.frameworks.Carbon + darwin.apple_sdk.frameworks.IOKit + ] ++ (drv.librarySystemDepends or []); + }); + +} diff --git a/pkgs/development/haskell-modules/configuration-nix.nix b/pkgs/development/haskell-modules/configuration-nix.nix index d29105ac6a3..f804b8288bd 100644 --- a/pkgs/development/haskell-modules/configuration-nix.nix +++ b/pkgs/development/haskell-modules/configuration-nix.nix @@ -101,17 +101,6 @@ self: super: builtins.intersectAttrs super { ormolu = enableSeparateBinOutput super.ormolu; ghcid = enableSeparateBinOutput super.ghcid; - # Ensure the necessary frameworks for Darwin. - OpenAL = if pkgs.stdenv.isDarwin - then addExtraLibrary super.OpenAL pkgs.darwin.apple_sdk.frameworks.OpenAL - else super.OpenAL; - - # Ensure the necessary frameworks for Darwin. - proteaaudio = if pkgs.stdenv.isDarwin - then addExtraLibrary super.proteaaudio pkgs.darwin.apple_sdk.frameworks.AudioToolbox - else super.proteaaudio; - - hzk = overrideCabal super.hzk (drv: { preConfigure = "sed -i -e /include-dirs/d hzk.cabal"; configureFlags = [ "--extra-include-dirs=${pkgs.zookeeper_mt}/include/zookeeper" ]; @@ -131,39 +120,11 @@ self: super: builtins.intersectAttrs super { # Foreign dependency name clashes with another Haskell package. libarchive-conduit = super.libarchive-conduit.override { archive = pkgs.libarchive; }; - # Fix Darwin build. - halive = if pkgs.stdenv.isDarwin - then addBuildDepend super.halive pkgs.darwin.apple_sdk.frameworks.AppKit - else super.halive; - # Heist's test suite requires system pandoc heist = overrideCabal super.heist (drv: { testToolDepends = [pkgs.pandoc]; }); - # the system-fileio tests use canonicalizePath, which fails in the sandbox - system-fileio = if pkgs.stdenv.isDarwin then dontCheck super.system-fileio else super.system-fileio; - - # Prevents needing to add `security_tool` as a run-time dependency for - # everything using x509-system to give access to the `security` executable. - x509-system = - if pkgs.stdenv.hostPlatform.isDarwin && !pkgs.stdenv.cc.nativeLibc - then - # darwin.security_tool is broken in Mojave (#45042) - - # We will use the system provided security for now. - # Beware this WILL break in sandboxes! - - # TODO(matthewbauer): If someone really needs this to work in sandboxes, - # I think we can add a propagatedImpureHost dep here, but I’m hoping to - # get a proper fix available soonish. - overrideCabal super.x509-system (drv: { - postPatch = (drv.postPatch or "") + '' - substituteInPlace System/X509/MacOS.hs --replace security /usr/bin/security - ''; - }) - else super.x509-system; - # https://github.com/NixOS/cabal2nix/issues/136 and https://github.com/NixOS/cabal2nix/issues/216 gio = disableHardening (addPkgconfigDepend (addBuildTool super.gio self.buildHaskellPackages.gtk2hs-buildtools) pkgs.glib) ["fortify"]; glib = disableHardening (addPkgconfigDepend (addBuildTool super.glib self.buildHaskellPackages.gtk2hs-buildtools) pkgs.glib) ["fortify"]; @@ -266,12 +227,6 @@ self: super: builtins.intersectAttrs super { # /homeless-shelter. Disabled. purescript = dontCheck super.purescript; - # https://github.com/haskell-foundation/foundation/pull/412 - foundation = - if pkgs.stdenv.isDarwin - then dontCheck super.foundation - else super.foundation; - # Hardcoded include path poppler = overrideCabal super.poppler (drv: { postPatch = '' @@ -283,23 +238,7 @@ self: super: builtins.intersectAttrs super { # Uses OpenGL in testing caramia = dontCheck super.caramia; - llvm-hs = - let llvmHsWithLlvm9 = super.llvm-hs.override { llvm-config = pkgs.llvm_9; }; - in - if pkgs.stdenv.isDarwin - then - overrideCabal llvmHsWithLlvm9 (oldAttrs: { - # One test fails on darwin. - doCheck = false; - # llvm-hs's Setup.hs file tries to add the lib/ directory from LLVM8 to - # the DYLD_LIBRARY_PATH environment variable. This messes up clang - # when called from GHC, probably because clang is version 7, but we are - # using LLVM8. - preCompileBuildDriver = oldAttrs.preCompileBuildDriver or "" + '' - substituteInPlace Setup.hs --replace "addToLdLibraryPath libDir" "pure ()" - ''; - }) - else llvmHsWithLlvm9; + llvm-hs = super.llvm-hs.override { llvm-config = pkgs.llvm_9; }; # Needs help finding LLVM. spaceprobe = addBuildTool super.spaceprobe self.llvmPackages.llvm; @@ -322,14 +261,6 @@ self: super: builtins.intersectAttrs super { # Patch to consider NIX_GHC just like xmonad does dyre = appendPatch super.dyre ./patches/dyre-nix.patch; - yesod-bin = if pkgs.stdenv.isDarwin - then addBuildDepend super.yesod-bin pkgs.darwin.apple_sdk.frameworks.Cocoa - else super.yesod-bin; - - hmatrix = if pkgs.stdenv.isDarwin - then addBuildDepend super.hmatrix pkgs.darwin.apple_sdk.frameworks.Accelerate - else super.hmatrix; - # https://github.com/edwinb/EpiVM/issues/13 # https://github.com/edwinb/EpiVM/issues/14 epic = addExtraLibraries (addBuildTool super.epic self.buildHaskellPackages.happy) [pkgs.boehmgc pkgs.gmp]; @@ -405,43 +336,8 @@ self: super: builtins.intersectAttrs super { # Looks like Avahi provides the missing library dnssd = super.dnssd.override { dns_sd = pkgs.avahi.override { withLibdnssdCompat = true; }; }; - # Ensure the necessary frameworks are propagatedBuildInputs on darwin - OpenGLRaw = overrideCabal super.OpenGLRaw (drv: { - librarySystemDepends = - pkgs.lib.optionals (!pkgs.stdenv.isDarwin) drv.librarySystemDepends; - libraryHaskellDepends = drv.libraryHaskellDepends - ++ pkgs.lib.optionals pkgs.stdenv.isDarwin - [ pkgs.darwin.apple_sdk.frameworks.OpenGL ]; - preConfigure = pkgs.lib.optionalString pkgs.stdenv.isDarwin '' - frameworkPaths=($(for i in $nativeBuildInputs; do if [ -d "$i"/Library/Frameworks ]; then echo "-F$i/Library/Frameworks"; fi done)) - frameworkPaths=$(IFS=, ; echo "''${frameworkPaths[@]}") - configureFlags+=$(if [ -n "$frameworkPaths" ]; then echo -n "--ghc-options=-optl=$frameworkPaths"; fi) - ''; - }); - GLURaw = overrideCabal super.GLURaw (drv: { - librarySystemDepends = - pkgs.lib.optionals (!pkgs.stdenv.isDarwin) drv.librarySystemDepends; - libraryHaskellDepends = drv.libraryHaskellDepends - ++ pkgs.lib.optionals pkgs.stdenv.isDarwin - [ pkgs.darwin.apple_sdk.frameworks.OpenGL ]; - }); - bindings-GLFW = overrideCabal super.bindings-GLFW (drv: { - doCheck = false; # requires an active X11 display - librarySystemDepends = - pkgs.lib.optionals (!pkgs.stdenv.isDarwin) drv.librarySystemDepends; - libraryHaskellDepends = drv.libraryHaskellDepends - ++ pkgs.lib.optionals pkgs.stdenv.isDarwin - (with pkgs.darwin.apple_sdk.frameworks; - [ AGL Cocoa OpenGL IOKit Kernel CoreVideo - pkgs.darwin.CF ]); - }); - OpenCL = overrideCabal super.OpenCL (drv: { - librarySystemDepends = - pkgs.lib.optionals (!pkgs.stdenv.isDarwin) drv.librarySystemDepends; - libraryHaskellDepends = drv.libraryHaskellDepends - ++ pkgs.lib.optionals pkgs.stdenv.isDarwin - [ pkgs.darwin.apple_sdk.frameworks.OpenCL ]; - }); + # requires an X11 display + bindings-GLFW = dontCheck super.bindings-GLFW; # requires an X11 display in test suite gi-gtk-declarative = dontCheck super.gi-gtk-declarative; @@ -474,16 +370,8 @@ self: super: builtins.intersectAttrs super { testHaskellDepends = (drv.testHaskellDepends or []) ++ [ self.test-framework self.test-framework-hunit ]; }); - # cabal2nix likes to generate dependencies on hinotify when hfsevents is really required - # on darwin: https://github.com/NixOS/cabal2nix/issues/146. - hinotify = if pkgs.stdenv.isDarwin then self.hfsevents else super.hinotify; - - # FSEvents API is very buggy and tests are unreliable. See - # http://openradar.appspot.com/10207999 and similar issues. # https://github.com/haskell-fswatch/hfsnotify/issues/62 - fsnotify = if pkgs.stdenv.isDarwin - then addBuildDepend (dontCheck super.fsnotify) pkgs.darwin.apple_sdk.frameworks.Cocoa - else dontCheck super.fsnotify; + fsnotify = dontCheck super.fsnotify; hidapi = addExtraLibrary super.hidapi pkgs.udev; @@ -844,21 +732,6 @@ self: super: builtins.intersectAttrs super { '' + (drv.postInstall or ""); }); - FractalArt = overrideCabal super.FractalArt (drv: { - librarySystemDepends = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin [ - pkgs.darwin.libobjc - pkgs.darwin.apple_sdk.frameworks.AppKit - ] ++ (drv.librarySystemDepends or []); - }); - - arbtt = overrideCabal super.arbtt (drv: { - librarySystemDepends = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin [ - pkgs.darwin.apple_sdk.frameworks.Foundation - pkgs.darwin.apple_sdk.frameworks.Carbon - pkgs.darwin.apple_sdk.frameworks.IOKit - ] ++ (drv.librarySystemDepends or []); - }); - # set more accurate set of platforms instead of maintaining # an ever growing list of platforms to exclude via unsupported-platforms cpuid = overrideCabal super.cpuid { diff --git a/pkgs/development/haskell-modules/default.nix b/pkgs/development/haskell-modules/default.nix index d4430f7a9f1..8392e751da2 100644 --- a/pkgs/development/haskell-modules/default.nix +++ b/pkgs/development/haskell-modules/default.nix @@ -8,6 +8,7 @@ , configurationCommon ? import ./configuration-common.nix , configurationNix ? import ./configuration-nix.nix , configurationArm ? import ./configuration-arm.nix +, configurationDarwin ? import ./configuration-darwin.nix }: let @@ -23,6 +24,8 @@ let isArm = with stdenv.hostPlatform; isAarch64 || isAarch32; platformConfigurations = lib.optionals isArm [ (configurationArm { inherit pkgs haskellLib; }) + ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ + (configurationDarwin { inherit pkgs haskellLib; }) ]; extensions = lib.composeManyExtensions ([