1
1
mirror of https://github.com/coot/free-category.git synced 2024-11-26 10:13:56 +03:00

Use callCabal2nix

This commit is contained in:
Marcin Szamotulski 2019-01-08 22:07:22 +01:00
parent 2cc5f7ac38
commit 7efa4c4430
No known key found for this signature in database
GPG Key ID: 788D56E52D63FAA4
3 changed files with 20 additions and 64 deletions

View File

@ -10,6 +10,7 @@ let
pkgs = nixpkgs.haskell.packages;
lib = nixpkgs.haskell.lib;
callCabal2nix = nixpkgs.haskell.packages.${compiler}.callCabal2nix;
doHaddock = if haddock
then lib.doHaddock
@ -23,12 +24,23 @@ let
doDev = if dev
then drv: lib.appendConfigureFlag drv "--ghc-option -Werror"
else nixpkgs.lib.id;
free-category = doDev(doHaddock(doTest(doBench(
pkgs.${compiler}.callPackage ./pkg.nix
{ inherit nixpkgs; }))));
examples = doDev(doHaddock(doTest(doBench(
pkgs.${compiler}.callPackage ./examples/pkg.nix
{ inherit free-category nixpkgs; }))));
docNoSeprateOutput = drv: lib.overrideCabal drv (drv: { enableSeparateDocOutput = false; });
srcFilter = src: path: type:
let relPath = nixpkgs.lib.removePrefix (toString src + "/") (toString path);
in
{ inherit free-category examples; }
nixpkgs.lib.hasPrefix "src" relPath
|| nixpkgs.lib.hasPrefix "test" relPath
|| nixpkgs.lib.any
(a: a == relPath)
[ "Setup.hs" "cabal.project" "ChangeLog.md" "free-category.cabal" "LICENSE"];
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; }

View File

@ -1,23 +0,0 @@
{ nixpkgs
, mkDerivation
, base
, free-category
, free-algebras
, QuickCheck
, stdenv
}:
mkDerivation {
pname = "free-category-examples";
version = "0.0.1.0";
src = nixpkgs.lib.sourceFilesBySuffices ./.
[ ".hs" "LICENSE" "ChangeLog.md" "examples.cabal" ];
libraryHaskellDepends = [
base
free-category
free-algebras
QuickCheck
];
libraryToolDepends = [ ];
license = stdenv.lib.licenses.mpl20;
enableSeparateDocOutput = false;
}

33
pkg.nix
View File

@ -1,33 +0,0 @@
{ mkDerivation
, nixpkgs
, stdenv
, base
, free-algebras
}:
let
lib = nixpkgs.lib;
srcFilter = src: path: type:
let relPath = lib.removePrefix (toString src + "/") (toString path);
in
lib.hasPrefix "src" relPath
|| lib.hasPrefix "test" relPath
|| lib.any
(a: a == relPath)
[ "Setup.hs" "cabal.project" "ChangeLog.md" "free-category.cabal" "LICENSE"];
in
mkDerivation {
pname = "free-category";
version = "0.0.1.0";
src = lib.cleanSourceWith { filter = srcFilter ./.; src = ./.; };
libraryHaskellDepends = [
base
free-algebras
];
libraryToolDepends = [ ];
testHaskellDepends = [
base
];
homepage = "https://github.com/coot/free-algebras#readme";
license = stdenv.lib.licenses.mpl20;
enableSeparateDocOutput = false;
}