1
1
mirror of https://github.com/coot/free-category.git synced 2024-11-23 00:56:58 +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; pkgs = nixpkgs.haskell.packages;
lib = nixpkgs.haskell.lib; lib = nixpkgs.haskell.lib;
callCabal2nix = nixpkgs.haskell.packages.${compiler}.callCabal2nix;
doHaddock = if haddock doHaddock = if haddock
then lib.doHaddock then lib.doHaddock
@ -23,12 +24,23 @@ let
doDev = if dev doDev = if dev
then drv: lib.appendConfigureFlag drv "--ghc-option -Werror" then drv: lib.appendConfigureFlag drv "--ghc-option -Werror"
else nixpkgs.lib.id; else nixpkgs.lib.id;
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
|| nixpkgs.lib.any
(a: a == relPath)
[ "Setup.hs" "cabal.project" "ChangeLog.md" "free-category.cabal" "LICENSE"];
free-category = doDev(doHaddock(doTest(doBench( free-category = docNoSeprateOutput(doDev(doHaddock(doTest(doBench(
pkgs.${compiler}.callPackage ./pkg.nix lib.overrideCabal (callCabal2nix "free-category" ./. {})
{ inherit nixpkgs; })))); (drv: {src = nixpkgs.lib.cleanSourceWith { filter = srcFilter drv.src; src = drv.src; };})
examples = doDev(doHaddock(doTest(doBench( )))));
pkgs.${compiler}.callPackage ./examples/pkg.nix examples = docNoSeprateOutput(doDev(doHaddock(doTest(doBench(
{ inherit free-category nixpkgs; })))); lib.overrideCabal (callCabal2nix "examples" ./examples { inherit free-category; })
in (drv: {src = nixpkgs.lib.sourceFilesBySuffices drv.src [ ".hs" "LICENSE" "ChangeLog.md" "examples.cabal" ];})
{ inherit free-category examples; } )))));
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;
}