2017-08-01 17:44:08 +01:00
|
|
|
# TODO(@Ericson2314): Remove `pkgs` param, which is only used for
|
2017-08-30 13:40:54 +01:00
|
|
|
# `buildStackProject`, `justStaticExecutables` and `checkUnusedPackages`
|
2017-08-01 17:44:08 +01:00
|
|
|
{ pkgs, lib }:
|
2015-01-10 19:26:08 +00:00
|
|
|
|
|
|
|
rec {
|
2017-10-31 20:50:23 +00:00
|
|
|
/* This function takes a file like `hackage-packages.nix` and constructs
|
|
|
|
a full package set out of that.
|
|
|
|
*/
|
2017-08-01 17:44:08 +01:00
|
|
|
makePackageSet = import ./make-package-set.nix;
|
2015-01-07 19:31:32 +00:00
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* The function overrideCabal lets you alter the arguments to the
|
|
|
|
mkDerivation function.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
First, note how the aeson package is constructed in hackage-packages.nix:
|
|
|
|
|
|
|
|
"aeson" = callPackage ({ mkDerivation, attoparsec, <snip>
|
|
|
|
}:
|
|
|
|
mkDerivation {
|
|
|
|
pname = "aeson";
|
|
|
|
<snip>
|
|
|
|
homepage = "https://github.com/bos/aeson";
|
|
|
|
})
|
|
|
|
|
|
|
|
The mkDerivation function of haskellPackages will take care of putting
|
|
|
|
the homepage in the right place, in meta.
|
|
|
|
|
|
|
|
> haskellPackages.aeson.meta.homepage
|
|
|
|
"https://github.com/bos/aeson"
|
|
|
|
|
|
|
|
> x = haskell.lib.overrideCabal haskellPackages.aeson (old: { homepage = old.homepage + "#readme"; })
|
|
|
|
> x.meta.homepage
|
|
|
|
"https://github.com/bos/aeson#readme"
|
|
|
|
|
|
|
|
*/
|
2015-01-12 17:20:42 +00:00
|
|
|
overrideCabal = drv: f: (drv.override (args: args // {
|
2017-02-10 05:04:17 +00:00
|
|
|
mkDerivation = drv: (args.mkDerivation drv).override f;
|
2015-01-12 17:20:42 +00:00
|
|
|
})) // {
|
2015-01-12 17:18:46 +00:00
|
|
|
overrideScope = scope: overrideCabal (drv.overrideScope scope) f;
|
2015-01-12 17:20:42 +00:00
|
|
|
};
|
2015-01-07 19:31:32 +00:00
|
|
|
|
2018-01-18 21:37:47 +00:00
|
|
|
# : Map Name (Either Path VersionNumber) -> HaskellPackageOverrideSet
|
|
|
|
# Given a set whose values are either paths or version strings, produces
|
|
|
|
# a package override set (i.e. (self: super: { etc. })) that sets
|
|
|
|
# the packages named in the input set to the corresponding versions
|
|
|
|
packageSourceOverrides =
|
|
|
|
overrides: self: super: pkgs.lib.mapAttrs (name: src:
|
|
|
|
let isPath = x: builtins.substring 0 1 (toString x) == "/";
|
|
|
|
generateExprs = if isPath src
|
|
|
|
then self.callCabal2nix
|
|
|
|
else self.callHackage;
|
|
|
|
in generateExprs name src {}) overrides;
|
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* doCoverage modifies a haskell package to enable the generation
|
|
|
|
and installation of a coverage report.
|
|
|
|
|
|
|
|
See https://wiki.haskell.org/Haskell_program_coverage
|
|
|
|
*/
|
2017-02-14 15:17:40 +00:00
|
|
|
doCoverage = drv: overrideCabal drv (drv: { doCoverage = true; });
|
2017-10-31 20:50:23 +00:00
|
|
|
|
|
|
|
/* dontCoverage modifies a haskell package to disable the generation
|
|
|
|
and installation of a coverage report.
|
|
|
|
*/
|
2017-02-14 15:17:40 +00:00
|
|
|
dontCoverage = drv: overrideCabal drv (drv: { doCoverage = false; });
|
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* doHaddock modifies a haskell package to enable the generation and
|
|
|
|
installation of API documentation from code comments using the
|
|
|
|
haddock tool.
|
|
|
|
*/
|
2015-01-18 10:04:38 +00:00
|
|
|
doHaddock = drv: overrideCabal drv (drv: { doHaddock = true; });
|
2017-10-31 20:50:23 +00:00
|
|
|
|
|
|
|
/* dontHaddock modifies a haskell package to disable the generation and
|
|
|
|
installation of API documentation from code comments using the
|
|
|
|
haddock tool.
|
|
|
|
*/
|
2015-01-18 10:04:38 +00:00
|
|
|
dontHaddock = drv: overrideCabal drv (drv: { doHaddock = false; });
|
2015-01-10 19:26:08 +00:00
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* doJailbreak enables the removal of version bounds from the cabal
|
|
|
|
file. You may want to avoid this function.
|
|
|
|
|
|
|
|
This is useful when a package reports that it can not be built
|
|
|
|
due to version mismatches. In some cases, removing the version
|
|
|
|
bounds entirely is an easy way to make a package build, but at
|
|
|
|
the risk of breaking software in non-obvious ways now or in the
|
|
|
|
future.
|
|
|
|
|
|
|
|
Instead of jailbreaking, you can patch the cabal file.
|
|
|
|
*/
|
2015-01-10 19:26:08 +00:00
|
|
|
doJailbreak = drv: overrideCabal drv (drv: { jailbreak = true; });
|
2017-10-31 20:50:23 +00:00
|
|
|
|
|
|
|
/* dontJailbreak restores the use of the version bounds the check
|
|
|
|
the use of dependencies in the package description.
|
|
|
|
*/
|
2015-01-10 19:26:08 +00:00
|
|
|
dontJailbreak = drv: overrideCabal drv (drv: { jailbreak = false; });
|
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* doCheck enables dependency checking, compilation and execution
|
|
|
|
of test suites listed in the package description file.
|
|
|
|
*/
|
2015-01-12 00:28:15 +00:00
|
|
|
doCheck = drv: overrideCabal drv (drv: { doCheck = true; });
|
2017-10-31 20:50:23 +00:00
|
|
|
/* dontCheck disables dependency checking, compilation and execution
|
|
|
|
of test suites listed in the package description file.
|
|
|
|
*/
|
2015-01-10 19:26:08 +00:00
|
|
|
dontCheck = drv: overrideCabal drv (drv: { doCheck = false; });
|
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* doBenchmark enables dependency checking, compilation and execution
|
|
|
|
for benchmarks listed in the package description file.
|
|
|
|
*/
|
2017-09-19 14:55:16 +01:00
|
|
|
doBenchmark = drv: overrideCabal drv (drv: { doBenchmark = true; });
|
2017-10-31 20:50:23 +00:00
|
|
|
/* dontBenchmark disables dependency checking, compilation and execution
|
|
|
|
for benchmarks listed in the package description file.
|
|
|
|
*/
|
2017-09-19 14:55:16 +01:00
|
|
|
dontBenchmark = drv: overrideCabal drv (drv: { doBenchmark = false; });
|
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* doDistribute enables the distribution of binaries for the package
|
|
|
|
via hydra.
|
|
|
|
*/
|
2015-09-15 14:02:39 +01:00
|
|
|
doDistribute = drv: overrideCabal drv (drv: { hydraPlatforms = drv.platforms or ["i686-linux" "x86_64-linux" "x86_64-darwin"]; });
|
2017-10-31 20:50:23 +00:00
|
|
|
/* dontDistribute disables the distribution of binaries for the package
|
|
|
|
via hydra.
|
|
|
|
*/
|
2015-01-10 19:26:08 +00:00
|
|
|
dontDistribute = drv: overrideCabal drv (drv: { hydraPlatforms = []; });
|
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* appendConfigureFlag adds a single argument that will be passed to the
|
|
|
|
cabal configure command, after the arguments that have been defined
|
|
|
|
in the initial declaration or previous overrides.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
> haskell.lib.appendConfigureFlag haskellPackages.servant "--profiling-detail=all-functions"
|
|
|
|
*/
|
2015-01-12 00:28:15 +00:00
|
|
|
appendConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = (drv.configureFlags or []) ++ [x]; });
|
2017-10-31 20:50:23 +00:00
|
|
|
|
2018-03-17 08:55:39 +00:00
|
|
|
appendBuildFlag = drv: x: overrideCabal drv (drv: { buildFlags = (drv.buildFlags or []) ++ [x]; });
|
|
|
|
appendBuildFlags = drv: xs: overrideCabal drv (drv: { buildFlags = (drv.buildFlags or []) ++ xs; });
|
2017-10-31 20:50:23 +00:00
|
|
|
/* removeConfigureFlag drv x is a Haskell package like drv, but with
|
|
|
|
all cabal configure arguments that are equal to x removed.
|
|
|
|
|
|
|
|
> haskell.lib.removeConfigureFlag haskellPackages.servant "--verbose"
|
|
|
|
*/
|
2017-08-01 17:44:08 +01:00
|
|
|
removeConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = lib.remove x (drv.configureFlags or []); });
|
2015-01-10 19:26:08 +00:00
|
|
|
|
2015-01-19 13:59:04 +00:00
|
|
|
addBuildTool = drv: x: addBuildTools drv [x];
|
|
|
|
addBuildTools = drv: xs: overrideCabal drv (drv: { buildTools = (drv.buildTools or []) ++ xs; });
|
|
|
|
|
2015-02-03 11:24:13 +00:00
|
|
|
addExtraLibrary = drv: x: addExtraLibraries drv [x];
|
|
|
|
addExtraLibraries = drv: xs: overrideCabal drv (drv: { extraLibraries = (drv.extraLibraries or []) ++ xs; });
|
|
|
|
|
2015-01-20 22:50:38 +00:00
|
|
|
addBuildDepend = drv: x: addBuildDepends drv [x];
|
|
|
|
addBuildDepends = drv: xs: overrideCabal drv (drv: { buildDepends = (drv.buildDepends or []) ++ xs; });
|
|
|
|
|
2015-08-06 11:37:46 +01:00
|
|
|
addPkgconfigDepend = drv: x: addPkgconfigDepends drv [x];
|
2015-12-16 20:49:33 +00:00
|
|
|
addPkgconfigDepends = drv: xs: overrideCabal drv (drv: { pkgconfigDepends = (drv.pkgconfigDepends or []) ++ xs; });
|
2015-08-06 11:37:46 +01:00
|
|
|
|
2017-03-25 04:23:01 +00:00
|
|
|
addSetupDepend = drv: x: addSetupDepends drv [x];
|
|
|
|
addSetupDepends = drv: xs: overrideCabal drv (drv: { setupHaskellDepends = (drv.setupHaskellDepends or []) ++ xs; });
|
|
|
|
|
2015-01-10 19:26:08 +00:00
|
|
|
enableCabalFlag = drv: x: appendConfigureFlag (removeConfigureFlag drv "-f-${x}") "-f${x}";
|
|
|
|
disableCabalFlag = drv: x: appendConfigureFlag (removeConfigureFlag drv "-f${x}") "-f-${x}";
|
|
|
|
|
2018-01-19 14:50:20 +00:00
|
|
|
markBroken = drv: overrideCabal drv (drv: { broken = true; hydraPlatforms = []; });
|
2015-01-23 09:47:55 +00:00
|
|
|
markBrokenVersion = version: drv: assert drv.version == version; markBroken drv;
|
2015-01-12 15:12:33 +00:00
|
|
|
|
2015-01-13 11:28:17 +00:00
|
|
|
enableLibraryProfiling = drv: overrideCabal drv (drv: { enableLibraryProfiling = true; });
|
|
|
|
disableLibraryProfiling = drv: overrideCabal drv (drv: { enableLibraryProfiling = false; });
|
|
|
|
|
2018-03-29 18:32:17 +01:00
|
|
|
enableExecutableProfiling = drv: overrideCabal drv (drv: { enableExecutableProfiling = true; });
|
|
|
|
disableExecutableProfiling = drv: overrideCabal drv (drv: { enableExecutableProfiling = false; });
|
|
|
|
|
2015-02-06 11:10:56 +00:00
|
|
|
enableSharedExecutables = drv: overrideCabal drv (drv: { enableSharedExecutables = true; });
|
|
|
|
disableSharedExecutables = drv: overrideCabal drv (drv: { enableSharedExecutables = false; });
|
2015-01-13 11:28:17 +00:00
|
|
|
|
|
|
|
enableSharedLibraries = drv: overrideCabal drv (drv: { enableSharedLibraries = true; });
|
|
|
|
disableSharedLibraries = drv: overrideCabal drv (drv: { enableSharedLibraries = false; });
|
|
|
|
|
2017-01-02 16:19:28 +00:00
|
|
|
enableDeadCodeElimination = drv: overrideCabal drv (drv: { enableDeadCodeElimination = true; });
|
|
|
|
disableDeadCodeElimination = drv: overrideCabal drv (drv: { enableDeadCodeElimination = false; });
|
2015-01-13 11:28:17 +00:00
|
|
|
|
|
|
|
enableStaticLibraries = drv: overrideCabal drv (drv: { enableStaticLibraries = true; });
|
|
|
|
disableStaticLibraries = drv: overrideCabal drv (drv: { enableStaticLibraries = false; });
|
|
|
|
|
2015-01-23 09:47:55 +00:00
|
|
|
appendPatch = drv: x: appendPatches drv [x];
|
|
|
|
appendPatches = drv: xs: overrideCabal drv (drv: { patches = (drv.patches or []) ++ xs; });
|
|
|
|
|
2015-04-01 15:42:52 +01:00
|
|
|
doHyperlinkSource = drv: overrideCabal drv (drv: { hyperlinkSource = true; });
|
|
|
|
dontHyperlinkSource = drv: overrideCabal drv (drv: { hyperlinkSource = false; });
|
|
|
|
|
2016-09-14 17:58:46 +01:00
|
|
|
disableHardening = drv: flags: overrideCabal drv (drv: { hardeningDisable = flags; });
|
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* Let Nix strip the binary files.
|
|
|
|
* This removes debugging symbols.
|
|
|
|
*/
|
2017-09-01 15:49:50 +01:00
|
|
|
doStrip = drv: overrideCabal drv (drv: { dontStrip = false; });
|
2017-10-31 20:50:23 +00:00
|
|
|
|
|
|
|
/* Stop Nix from stripping the binary files.
|
|
|
|
* This keeps debugging symbols.
|
|
|
|
*/
|
2017-09-01 15:49:50 +01:00
|
|
|
dontStrip = drv: overrideCabal drv (drv: { dontStrip = true; });
|
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* Useful for debugging segfaults with gdb.
|
|
|
|
* This includes dontStrip.
|
|
|
|
*/
|
2017-09-01 15:49:50 +01:00
|
|
|
enableDWARFDebugging = drv:
|
2017-10-31 20:50:23 +00:00
|
|
|
# -g: enables debugging symbols
|
|
|
|
# --disable-*-stripping: tell GHC not to strip resulting binaries
|
|
|
|
# dontStrip: see above
|
2017-09-01 15:49:50 +01:00
|
|
|
appendConfigureFlag (dontStrip drv) "--ghc-options=-g --disable-executable-stripping --disable-library-stripping";
|
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* Create a source distribution tarball like those found on hackage,
|
|
|
|
instead of building the package.
|
|
|
|
*/
|
2017-08-01 17:44:08 +01:00
|
|
|
sdistTarball = pkg: lib.overrideDerivation pkg (drv: {
|
2015-06-02 12:58:57 +01:00
|
|
|
name = "${drv.pname}-source-${drv.version}";
|
2017-08-10 07:47:07 +01:00
|
|
|
# Since we disable the haddock phase, we also need to override the
|
|
|
|
# outputs since the separate doc output will not be produced.
|
|
|
|
outputs = ["out"];
|
2015-06-02 12:58:57 +01:00
|
|
|
buildPhase = "./Setup sdist";
|
|
|
|
haddockPhase = ":";
|
|
|
|
checkPhase = ":";
|
2015-08-30 14:18:15 +01:00
|
|
|
installPhase = "install -D dist/${drv.pname}-*.tar.gz $out/${drv.pname}-${drv.version}.tar.gz";
|
2015-06-02 12:58:57 +01:00
|
|
|
fixupPhase = ":";
|
|
|
|
});
|
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* Use the gold linker. It is a linker for ELF that is designed
|
|
|
|
"to run as fast as possible on modern systems"
|
|
|
|
*/
|
2017-04-07 00:28:44 +01:00
|
|
|
linkWithGold = drv : appendConfigureFlag drv
|
|
|
|
"--ghc-option=-optl-fuse-ld=gold --ld-option=-fuse-ld=gold --with-ld=ld.gold";
|
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* link executables statically against haskell libs to reduce
|
|
|
|
closure size
|
|
|
|
*/
|
2017-03-07 17:13:59 +00:00
|
|
|
justStaticExecutables = drv: overrideCabal drv (drv: {
|
|
|
|
enableSharedExecutables = false;
|
|
|
|
isLibrary = false;
|
|
|
|
doHaddock = false;
|
|
|
|
postFixup = "rm -rf $out/lib $out/nix-support $out/share/doc";
|
2017-08-01 17:44:08 +01:00
|
|
|
});
|
2017-03-07 17:13:59 +00:00
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* Build a source distribution tarball instead of using the source files
|
|
|
|
directly. The effect is that the package is built as if it were published
|
|
|
|
on hackage. This can be used as a test for the source distribution,
|
|
|
|
assuming the build fails when packaging mistakes are in the cabal file.
|
|
|
|
*/
|
2017-08-01 17:44:08 +01:00
|
|
|
buildFromSdist = pkg: lib.overrideDerivation pkg (drv: {
|
2015-06-02 12:58:57 +01:00
|
|
|
unpackPhase = let src = sdistTarball pkg; tarname = "${pkg.pname}-${pkg.version}"; in ''
|
|
|
|
echo "Source tarball is at ${src}/${tarname}.tar.gz"
|
|
|
|
tar xf ${src}/${tarname}.tar.gz
|
2015-08-30 14:18:15 +01:00
|
|
|
cd ${pkg.pname}-*
|
2015-06-02 12:58:57 +01:00
|
|
|
'';
|
|
|
|
});
|
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* Build the package in a strict way to uncover potential problems.
|
|
|
|
This includes buildFromSdist and failOnAllWarnings.
|
|
|
|
*/
|
2017-09-10 12:09:52 +01:00
|
|
|
buildStrictly = pkg: buildFromSdist (failOnAllWarnings pkg);
|
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* Turn on most of the compiler warnings and fail the build if any
|
|
|
|
of them occur. */
|
2017-09-10 12:09:52 +01:00
|
|
|
failOnAllWarnings = drv: appendConfigureFlag drv "--ghc-option=-Wall --ghc-option=-Werror";
|
2015-06-02 12:58:57 +01:00
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* Add a post-build check to verify that dependencies declared in
|
|
|
|
the cabal file are actually used.
|
|
|
|
|
|
|
|
The first attrset argument can be used to configure the strictness
|
2018-03-27 02:57:32 +01:00
|
|
|
of this check and a list of ignored package names that would otherwise
|
2017-10-31 20:50:23 +00:00
|
|
|
cause false alarms.
|
|
|
|
*/
|
2017-08-30 13:40:54 +01:00
|
|
|
checkUnusedPackages =
|
|
|
|
{ ignoreEmptyImports ? false
|
|
|
|
, ignoreMainModule ? false
|
|
|
|
, ignorePackages ? []
|
|
|
|
} : drv :
|
|
|
|
overrideCabal (appendConfigureFlag drv "--ghc-option=-ddump-minimal-imports") (_drv: {
|
|
|
|
postBuild = with lib;
|
|
|
|
let args = concatStringsSep " " (
|
|
|
|
optional ignoreEmptyImports "--ignore-empty-imports" ++
|
|
|
|
optional ignoreMainModule "--ignore-main-module" ++
|
|
|
|
map (pkg: "--ignore-package ${pkg}") ignorePackages
|
|
|
|
);
|
|
|
|
in "${pkgs.haskellPackages.packunused}/bin/packunused" +
|
|
|
|
optionalString (args != "") " ${args}";
|
|
|
|
});
|
|
|
|
|
2016-03-06 09:35:25 +00:00
|
|
|
buildStackProject = pkgs.callPackage ./generic-stack-builder.nix { };
|
2016-03-04 20:24:42 +00:00
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* Add a dummy command to trigger a build despite an equivalent
|
|
|
|
earlier build that is present in the store or cache.
|
|
|
|
*/
|
2015-06-06 23:05:17 +01:00
|
|
|
triggerRebuild = drv: i: overrideCabal drv (drv: { postUnpack = ": trigger rebuild ${toString i}"; });
|
|
|
|
|
2017-10-31 20:50:23 +00:00
|
|
|
/* Override the sources for the package and optionaly the version.
|
|
|
|
This also takes of removing editedCabalFile.
|
|
|
|
*/
|
2017-04-08 21:21:57 +01:00
|
|
|
overrideSrc = drv: { src, version ? drv.version }:
|
|
|
|
overrideCabal drv (_: { inherit src version; editedCabalFile = null; });
|
|
|
|
|
2017-12-29 02:29:23 +00:00
|
|
|
# Extract the haskell build inputs of a haskell package.
|
|
|
|
# This is useful to build environments for developing on that
|
|
|
|
# package.
|
|
|
|
getHaskellBuildInputs = p:
|
2018-05-18 01:35:53 +01:00
|
|
|
(overrideCabal p (args: {
|
|
|
|
passthru = (args.passthru or {}) // {
|
|
|
|
_getHaskellBuildInputs = extractBuildInputs p.compiler args;
|
|
|
|
};
|
|
|
|
}))._getHaskellBuildInputs;
|
2017-12-29 02:29:23 +00:00
|
|
|
|
2018-01-10 17:08:36 +00:00
|
|
|
# Under normal evaluation, simply return the original package. Under
|
|
|
|
# nix-shell evaluation, return a nix-shell optimized environment.
|
|
|
|
shellAware = p: if lib.inNixShell then p.env else p;
|
|
|
|
|
2017-12-29 02:29:23 +00:00
|
|
|
ghcInfo = ghc:
|
|
|
|
rec { isCross = (ghc.cross or null) != null;
|
|
|
|
isGhcjs = ghc.isGhcjs or false;
|
|
|
|
nativeGhc = if isCross || isGhcjs
|
|
|
|
then ghc.bootPkgs.ghc
|
|
|
|
else ghc;
|
|
|
|
};
|
|
|
|
|
|
|
|
### mkDerivation helpers
|
|
|
|
# These allow external users of a haskell package to extract
|
|
|
|
# information about how it is built in the same way that the
|
|
|
|
# generic haskell builder does, by reusing the same functions.
|
|
|
|
# Each function here has the same interface as mkDerivation and thus
|
|
|
|
# can be called for a given package simply by overriding the
|
|
|
|
# mkDerivation argument it used. See getHaskellBuildInputs above for
|
|
|
|
# an example of this.
|
|
|
|
|
|
|
|
# Some information about which phases should be run.
|
|
|
|
controlPhases = ghc: let inherit (ghcInfo ghc) isCross; in
|
|
|
|
{ doCheck ? !isCross && (lib.versionOlder "7.4" ghc.version)
|
|
|
|
, doBenchmark ? false
|
|
|
|
, ...
|
|
|
|
}: { inherit doCheck doBenchmark; };
|
|
|
|
|
|
|
|
# Divide the build inputs of the package into useful sets.
|
|
|
|
extractBuildInputs = ghc:
|
|
|
|
{ setupHaskellDepends ? [], extraLibraries ? []
|
|
|
|
, librarySystemDepends ? [], executableSystemDepends ? []
|
|
|
|
, pkgconfigDepends ? [], libraryPkgconfigDepends ? []
|
|
|
|
, executablePkgconfigDepends ? [], testPkgconfigDepends ? []
|
|
|
|
, benchmarkPkgconfigDepends ? [], testDepends ? []
|
|
|
|
, testHaskellDepends ? [], testSystemDepends ? []
|
|
|
|
, testToolDepends ? [], benchmarkDepends ? []
|
|
|
|
, benchmarkHaskellDepends ? [], benchmarkSystemDepends ? []
|
|
|
|
, benchmarkToolDepends ? [], buildDepends ? []
|
|
|
|
, libraryHaskellDepends ? [], executableHaskellDepends ? []
|
|
|
|
, ...
|
|
|
|
}@args:
|
|
|
|
let inherit (ghcInfo ghc) isGhcjs nativeGhc;
|
|
|
|
inherit (controlPhases ghc args) doCheck doBenchmark;
|
|
|
|
isHaskellPkg = x: x ? isHaskellLibrary;
|
|
|
|
allPkgconfigDepends =
|
|
|
|
pkgconfigDepends ++ libraryPkgconfigDepends ++
|
|
|
|
executablePkgconfigDepends ++
|
|
|
|
lib.optionals doCheck testPkgconfigDepends ++
|
|
|
|
lib.optionals doBenchmark benchmarkPkgconfigDepends;
|
|
|
|
otherBuildInputs =
|
|
|
|
setupHaskellDepends ++ extraLibraries ++
|
|
|
|
librarySystemDepends ++ executableSystemDepends ++
|
|
|
|
allPkgconfigDepends ++
|
|
|
|
lib.optionals doCheck ( testDepends ++ testHaskellDepends ++
|
|
|
|
testSystemDepends ++ testToolDepends
|
|
|
|
) ++
|
|
|
|
# ghcjs's hsc2hs calls out to the native hsc2hs
|
|
|
|
lib.optional isGhcjs nativeGhc ++
|
|
|
|
lib.optionals doBenchmark ( benchmarkDepends ++
|
|
|
|
benchmarkHaskellDepends ++
|
|
|
|
benchmarkSystemDepends ++
|
|
|
|
benchmarkToolDepends
|
|
|
|
);
|
|
|
|
propagatedBuildInputs =
|
|
|
|
buildDepends ++ libraryHaskellDepends ++
|
|
|
|
executableHaskellDepends;
|
|
|
|
allBuildInputs = propagatedBuildInputs ++ otherBuildInputs;
|
|
|
|
isHaskellPartition =
|
|
|
|
lib.partition isHaskellPkg allBuildInputs;
|
|
|
|
in
|
|
|
|
{ haskellBuildInputs = isHaskellPartition.right;
|
|
|
|
systemBuildInputs = isHaskellPartition.wrong;
|
|
|
|
inherit propagatedBuildInputs otherBuildInputs
|
|
|
|
allPkgconfigDepends;
|
|
|
|
};
|
|
|
|
|
2018-07-03 17:25:15 +01:00
|
|
|
# Utility to convert a directory full of `cabal2nix`-generated files into a
|
|
|
|
# package override set
|
|
|
|
#
|
2018-07-07 23:23:03 +01:00
|
|
|
# packagesFromDirectory : { directory : Directory, ... } -> HaskellPackageOverrideSet
|
2018-07-04 16:22:20 +01:00
|
|
|
packagesFromDirectory =
|
2018-07-06 12:03:56 +01:00
|
|
|
{ directory, ... }:
|
2018-07-03 17:25:15 +01:00
|
|
|
|
|
|
|
self: super:
|
|
|
|
let
|
|
|
|
haskellPaths = builtins.attrNames (builtins.readDir directory);
|
|
|
|
|
|
|
|
toKeyVal = file: {
|
|
|
|
name = builtins.replaceStrings [ ".nix" ] [ "" ] file;
|
|
|
|
|
|
|
|
value = self.callPackage (directory + "/${file}") { };
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
builtins.listToAttrs (map toKeyVal haskellPaths);
|
2015-01-07 19:31:32 +00:00
|
|
|
}
|