# NIX-SPECIFIC OVERRIDES/PATCHES FOR HASKELL PACKAGES
#
# This file contains overrides which are needed because of Nix. For example,
# some packages may need help finding the location of native libraries. In
# general, overrides in this file are (mostly) due to one of the following reasons:
#
# * packages that hard code the location of native libraries, so they need to be patched/
# supplied the patch explicitly
# * passing native libraries that are not detected correctly by cabal2nix
# * test suites that fail due to some features not available in the nix sandbox
# (networking being a common one)
#
# In general, this file should *not* contain overrides that fix build failures that could
# also occur on standard, FHS-compliant non-Nix systems. For example, if tests have a compile
# error, that is a bug in the package, and that failure has nothing to do with Nix.
#
# Common examples which should *not* be a part of this file:
#
# * overriding a specific version of a haskell library because some package fails
# to build with a newer version. Such overrides have nothing to do with Nix itself,
# and they would also be neccessary outside of Nix if you use the same set of
# package versions.
# * disabling tests that fail due to missing files in the tarball or compile errors
# * disabling tests that require too much memory
# * enabling/disabling certain features in packages
#
# If you have an override of this kind, see configuration-common.nix instead.
{ pkgs, haskellLib }:
let
inherit (pkgs) lib;
in
with haskellLib;
# All of the overrides in this set should look like:
#
# foo = ... something involving super.foo ...
#
# but that means that we add `foo` attribute even if there is no `super.foo`! So if
# you want to use this configuration for a package set that only contains a subset of
# the packages that have overrides defined here, you'll end up with a set that contains
# a bunch of attributes that trigger an evaluation error.
#
# To avoid this, we use `intersectAttrs` here so we never add packages that are not present
# in the parent package set (`super`).
self: super: builtins.intersectAttrs super {
# Apply NixOS-specific patches.
ghc-paths = appendPatch ./patches/ghc-paths-nix.patch super.ghc-paths;
# fix errors caused by hardening flags
epanet-haskell = disableHardening ["format"] super.epanet-haskell;
# Link the proper version.
zeromq4-haskell = super.zeromq4-haskell.override { zeromq = pkgs.zeromq4; };
# Use the default version of mysql to build this package (which is actually mariadb).
# test phase requires networking
mysql = dontCheck super.mysql;
# CUDA needs help finding the SDK headers and libraries.
cuda = overrideCabal (drv: {
extraLibraries = (drv.extraLibraries or []) ++ [pkgs.linuxPackages.nvidia_x11];
configureFlags = (drv.configureFlags or []) ++ [
"--extra-lib-dirs=${pkgs.cudatoolkit.lib}/lib"
"--extra-include-dirs=${pkgs.cudatoolkit}/include"
];
preConfigure = ''
export CUDA_PATH=${pkgs.cudatoolkit}
'';
}) super.cuda;
nvvm = overrideCabal (drv: {
preConfigure = ''
export CUDA_PATH=${pkgs.cudatoolkit}
'';
}) super.nvvm;
cufft = overrideCabal (drv: {
preConfigure = ''
export CUDA_PATH=${pkgs.cudatoolkit}
'';
}) super.cufft;
# jni needs help finding libjvm.so because it's in a weird location.
jni = overrideCabal (drv: {
preConfigure = ''
local libdir=( "${pkgs.jdk}/lib/openjdk/jre/lib/"*"/server" )
configureFlags+=" --extra-lib-dir=''${libdir[0]}"
'';
}) super.jni;
# Won't find it's header files without help.
sfml-audio = appendConfigureFlag "--extra-include-dirs=${pkgs.openal}/include/AL" super.sfml-audio;
# avoid compiling twice by providing executable as a separate output (with small closure size)
niv = enableSeparateBinOutput (self.generateOptparseApplicativeCompletions [ "niv" ] super.niv);
ghcid = enableSeparateBinOutput super.ghcid;
ormolu = self.generateOptparseApplicativeCompletions [ "ormolu" ] (enableSeparateBinOutput super.ormolu);
# Generate shell completion.
cabal2nix = self.generateOptparseApplicativeCompletions [ "cabal2nix" ] super.cabal2nix;
arbtt = overrideCabal (drv: {
# The test suite needs the packages's executables in $PATH to succeed.
preCheck = ''
for i in $PWD/dist/build/*; do
export PATH="$i:$PATH"
done
'';
# One test uses timezone data
testToolDepends = drv.testToolDepends or [] ++ [
pkgs.tzdata
];
}) super.arbtt;
hzk = appendConfigureFlag "--extra-include-dirs=${pkgs.zookeeper_mt}/include/zookeeper" super.hzk;
# Foreign dependency name clashes with another Haskell package.
libarchive-conduit = super.libarchive-conduit.override { archive = pkgs.libarchive; };
# Heist's test suite requires system pandoc
heist = addTestToolDepend pkgs.pandoc super.heist;
# https://github.com/NixOS/cabal2nix/issues/136 and https://github.com/NixOS/cabal2nix/issues/216
gio = disableHardening ["fortify"] (addPkgconfigDepend pkgs.glib (addBuildTool self.buildHaskellPackages.gtk2hs-buildtools super.gio));
glib = disableHardening ["fortify"] (addPkgconfigDepend pkgs.glib (addBuildTool self.buildHaskellPackages.gtk2hs-buildtools super.glib));
gtk3 = disableHardening ["fortify"] (super.gtk3.override { inherit (pkgs) gtk3; });
gtk = let gtk1 = addBuildTool self.buildHaskellPackages.gtk2hs-buildtools super.gtk;
gtk2 = addPkgconfigDepend pkgs.gtk2 gtk1;
gtk3 = disableHardening ["fortify"] gtk1;
gtk4 = if pkgs.stdenv.isDarwin then appendConfigureFlag "-fhave-quartz-gtk" gtk3 else gtk4;
in gtk3;
gtksourceview2 = addPkgconfigDepend pkgs.gtk2 super.gtksourceview2;
gtk-traymanager = addPkgconfigDepend pkgs.gtk3 super.gtk-traymanager;
# Add necessary reference to gtk3 package
gi-dbusmenugtk3 = addPkgconfigDepend pkgs.gtk3 super.gi-dbusmenugtk3