diff --git a/pkgs/development/haskell-modules/lib.nix b/pkgs/development/haskell-modules/lib.nix index 4d0954a5d7a..6bcc563164e 100644 --- a/pkgs/development/haskell-modules/lib.nix +++ b/pkgs/development/haskell-modules/lib.nix @@ -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" */ diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix index d9befb9350a..7ee7d21fd56 100644 --- a/pkgs/test/default.nix +++ b/pkgs/test/default.nix @@ -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; }; diff --git a/pkgs/test/haskell-documentationTarball/default.nix b/pkgs/test/haskell-documentationTarball/default.nix new file mode 100644 index 00000000000..aec3dc41f26 --- /dev/null +++ b/pkgs/test/haskell-documentationTarball/default.nix @@ -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" +''