2019-08-31 11:12:21 +03:00
|
|
|
{ compiler ? "ghc865"
|
2018-08-26 20:12:12 +03:00
|
|
|
, haddock ? true
|
|
|
|
, test ? true
|
|
|
|
, benchmarks ? false
|
|
|
|
, dev ? true
|
|
|
|
}:
|
|
|
|
with builtins;
|
|
|
|
let
|
2018-12-16 20:32:43 +03:00
|
|
|
nixpkgs = import ./nix/nixpkgs.nix { inherit compiler; };
|
2018-08-26 20:12:12 +03:00
|
|
|
|
|
|
|
pkgs = nixpkgs.haskell.packages;
|
|
|
|
lib = nixpkgs.haskell.lib;
|
2019-01-09 00:07:22 +03:00
|
|
|
callCabal2nix = nixpkgs.haskell.packages.${compiler}.callCabal2nix;
|
2018-08-26 20:12:12 +03:00
|
|
|
|
|
|
|
doHaddock = if haddock
|
|
|
|
then lib.doHaddock
|
|
|
|
else lib.dontHaddock;
|
|
|
|
doTest = if test
|
|
|
|
then lib.doCheck
|
|
|
|
else lib.dontCheck;
|
|
|
|
doBench = if benchmarks
|
|
|
|
then lib.doBenchmark
|
|
|
|
else nixpkgs.lib.id;
|
|
|
|
doDev = if dev
|
2018-10-22 01:09:31 +03:00
|
|
|
then drv: lib.appendConfigureFlag drv "--ghc-option -Werror"
|
2018-08-26 20:12:12 +03:00
|
|
|
else nixpkgs.lib.id;
|
2019-01-09 00:07:22 +03:00
|
|
|
docNoSeprateOutput = drv: lib.overrideCabal drv (drv: { enableSeparateDocOutput = false; });
|
|
|
|
srcFilter = src: path: type:
|
|
|
|
let relPath = nixpkgs.lib.removePrefix (toString src + "/") (toString path);
|
|
|
|
in
|
|
|
|
nixpkgs.lib.hasPrefix "src" relPath
|
|
|
|
|| nixpkgs.lib.hasPrefix "test" relPath
|
2019-09-07 13:45:26 +03:00
|
|
|
|| nixpkgs.lib.hasPrefix "bench" relPath
|
2019-01-09 00:07:22 +03:00
|
|
|
|| nixpkgs.lib.any
|
|
|
|
(a: a == relPath)
|
|
|
|
[ "Setup.hs" "cabal.project" "ChangeLog.md" "free-category.cabal" "LICENSE"];
|
2018-08-26 20:12:12 +03:00
|
|
|
|
2019-01-09 00:07:22 +03:00
|
|
|
free-category = docNoSeprateOutput(doDev(doHaddock(doTest(doBench(
|
|
|
|
lib.overrideCabal (callCabal2nix "free-category" ./. {})
|
|
|
|
(drv: {src = nixpkgs.lib.cleanSourceWith { filter = srcFilter drv.src; src = drv.src; };})
|
|
|
|
)))));
|
|
|
|
examples = docNoSeprateOutput(doDev(doHaddock(doTest(doBench(
|
|
|
|
lib.overrideCabal (callCabal2nix "examples" ./examples { inherit free-category; })
|
|
|
|
(drv: {src = nixpkgs.lib.sourceFilesBySuffices drv.src [ ".hs" "LICENSE" "ChangeLog.md" "examples.cabal" ];})
|
|
|
|
)))));
|
|
|
|
|
|
|
|
in { inherit free-category examples; }
|