From ba809cf9a3aa2aefe9721e003c07d53767f2032b Mon Sep 17 00:00:00 2001 From: Peter Simons Date: Tue, 2 Jun 2015 13:58:57 +0200 Subject: [PATCH] haskell: add three new helper functions to the lib module - sdistTarball transforms a normal Haskell build into one that produces a release tarball by running "sdist". For example: $ nix-shell -p "haskell.lib.sdistTarball haskellPackages.mtl" --command 'tar tfv $nativeBuildInputs/*tar.gz' - buildFromSdist transforms a normal Haskell build into one that compiles the package the an sdist release tarball created by Nix. For example: $ nix-shell -p "haskell.lib.buildFromSdist haskellPackages.mtl" --command "exit 0" - buildStrictly transforms a normal Haskell build into one that (a) compiles the source code with "-Wall -Werror" flags and (b) uses as input a locally generated sdist release tarball. For example: $ nix-shell -p "haskell.lib.buildStrictly haskellPackages.mtl" --command "exit 0" This function is particularly useful for continuous Hydra builds of Haskell packages. --- pkgs/development/haskell-modules/lib.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkgs/development/haskell-modules/lib.nix b/pkgs/development/haskell-modules/lib.nix index 8f932c870237..e601c7665ac4 100644 --- a/pkgs/development/haskell-modules/lib.nix +++ b/pkgs/development/haskell-modules/lib.nix @@ -58,4 +58,23 @@ rec { doHyperlinkSource = drv: overrideCabal drv (drv: { hyperlinkSource = true; }); dontHyperlinkSource = drv: overrideCabal drv (drv: { hyperlinkSource = false; }); + sdistTarball = pkg: pkgs.lib.overrideDerivation pkg (drv: { + name = "${drv.pname}-source-${drv.version}"; + buildPhase = "./Setup sdist"; + haddockPhase = ":"; + checkPhase = ":"; + installPhase = "install -D dist/${drv.pname}-${drv.version}.tar.gz $out/${drv.pname}-${drv.version}.tar.gz"; + fixupPhase = ":"; + }); + + buildFromSdist = pkg: pkgs.lib.overrideDerivation pkg (drv: { + unpackPhase = let src = sdistTarball pkg; tarname = "${pkg.pname}-${pkg.version}"; in '' + echo "Source tarball is at ${src}/${tarname}.tar.gz" + tar xf ${src}/${tarname}.tar.gz + cd ${tarname} + ''; + }); + + buildStrictly = pkg: buildFromSdist (appendConfigureFlag pkg "--ghc-option=-Wall --ghc-option=-Werror"); + }