From 7efa4c443008ac3e22bd20e4ea393682129b842e Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Tue, 8 Jan 2019 22:07:22 +0100 Subject: [PATCH] Use callCabal2nix --- default.nix | 28 ++++++++++++++++++++-------- examples/pkg.nix | 23 ----------------------- pkg.nix | 33 --------------------------------- 3 files changed, 20 insertions(+), 64 deletions(-) delete mode 100644 examples/pkg.nix delete mode 100644 pkg.nix diff --git a/default.nix b/default.nix index c0aed56..c535b87 100644 --- a/default.nix +++ b/default.nix @@ -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; + 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( - pkgs.${compiler}.callPackage ./pkg.nix - { inherit nixpkgs; })))); - examples = doDev(doHaddock(doTest(doBench( - pkgs.${compiler}.callPackage ./examples/pkg.nix - { inherit free-category nixpkgs; })))); -in -{ inherit free-category examples; } + 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; } diff --git a/examples/pkg.nix b/examples/pkg.nix deleted file mode 100644 index d656619..0000000 --- a/examples/pkg.nix +++ /dev/null @@ -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; -} diff --git a/pkg.nix b/pkg.nix deleted file mode 100644 index 62edfb5..0000000 --- a/pkg.nix +++ /dev/null @@ -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; -}