1
1
mirror of https://github.com/coot/free-category.git synced 2024-11-23 09:55:43 +03:00
free-category/default.nix

48 lines
1.6 KiB
Nix
Raw Normal View History

{ compiler ? "ghc865"
2018-08-26 20:12:12 +03:00
, haddock ? true
, test ? true
, benchmarks ? false
, dev ? true
}:
with builtins;
let
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; }