haskell: Add documentationTarball to lib

This commit is contained in:
Joe Hermaszewski 2020-11-07 17:50:17 +08:00 committed by Peter Simons
parent bbb5016daa
commit 7673eda11d
3 changed files with 43 additions and 0 deletions

View File

@ -235,6 +235,31 @@ rec {
fixupPhase = ":";
});
/* Create a documentation tarball suitable for uploading to Hackage instead
of building the package.
*/
documentationTarball = pkg:
pkgs.lib.overrideDerivation pkg (drv: {
name = "${drv.name}-docs";
# Like sdistTarball, disable the "doc" output here.
outputs = [ "out" ];
buildPhase = ''
runHook preHaddock
./Setup haddock --for-hackage
runHook postHaddock
'';
haddockPhase = ":";
checkPhase = ":";
installPhase = ''
runHook preInstall
mkdir -p "$out"
tar --format=ustar \
-czf "$out/${drv.name}-docs.tar.gz" \
-C dist/doc/html "${drv.name}-docs"
runHook postInstall
'';
});
/* Use the gold linker. It is a linker for ELF that is designed
"to run as fast as possible on modern systems"
*/

View File

@ -23,6 +23,7 @@ with pkgs;
stdenv-inputs = callPackage ./stdenv-inputs { };
haskell-shellFor = callPackage ./haskell-shellFor { };
haskell-documentationTarball = callPackage ./haskell-documentationTarball { };
cc-multilib-gcc = callPackage ./cc-wrapper/multilib.nix { stdenv = gccMultiStdenv; };
cc-multilib-clang = callPackage ./cc-wrapper/multilib.nix { stdenv = clangMultiStdenv; };

View File

@ -0,0 +1,17 @@
{ pkgs, haskellPackages }:
let
drv = haskellPackages.vector;
docs = pkgs.haskell.lib.documentationTarball drv;
in pkgs.runCommand "test haskell.lib.documentationTarball" { } ''
tar xvzf "${docs}/${drv.name}-docs.tar.gz"
# Check for Haddock html
find "${drv.name}-docs" | grep -q "Data-Vector.html"
# Check for source html
find "${drv.name}-docs" | grep -q "src/Data.Vector.html"
touch "$out"
''