haskell.packages: move darwin-specific overrides into their own config

This commit is contained in:
sternenseemann
2021-05-08 19:56:05 +02:00
parent b47b2f5ab7
commit 312d3bf74b
4 changed files with 173 additions and 176 deletions
@@ -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 Im 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 {