diff options
author | Pepe Iborra <pepeiborra@gmail.com> | 2020-06-23 14:18:56 +0100 |
---|---|---|
committer | sternenseemann <sternenseemann@systemli.org> | 2021-11-10 21:10:35 +0100 |
commit | d68033afae8476a840a3d6866f9119a78e5dec84 (patch) | |
tree | 038126234ee271b704a90e420bfdec2e07ac1806 /pkgs/development/haskell-modules/generic-builder.nix | |
parent | da2c9c6eabc7f94675736bab02d1d70726410764 (diff) | |
download | nixpkgs-d68033afae8476a840a3d6866f9119a78e5dec84.tar nixpkgs-d68033afae8476a840a3d6866f9119a78e5dec84.tar.gz nixpkgs-d68033afae8476a840a3d6866f9119a78e5dec84.tar.bz2 nixpkgs-d68033afae8476a840a3d6866f9119a78e5dec84.tar.lz nixpkgs-d68033afae8476a840a3d6866f9119a78e5dec84.tar.xz nixpkgs-d68033afae8476a840a3d6866f9119a78e5dec84.tar.zst nixpkgs-d68033afae8476a840a3d6866f9119a78e5dec84.zip |
haskellPackages.mkDerivation: add doHaddockInterfaces option
This adds a new builder option `doHaddockInterfaces` to enable the -haddock flag in GHC, which results in Haddock comments parsed at compile-time and embedded in interface files. These are used by the :doc command in GHCi, as well as IDE tools like ghcide and hls to display docs on hover. The `-haddock` flag has been around since at least 8.2, even though it does not get a mention in the GHC Users guide. There are two downsides to turning on this flag: 1. Increased compile times, since Haddocks must be parsed and then encoded 2. Haddock parse errors now become compile errors for GHC < 9.0.1 (https://gitlab.haskell.org/ghc/ghc/-/issues/8944) Thus we only enable the feature if we have GHC 9.0.1 and haddock is enabled; when 9.0.1 becomes the default GHC, we may need to reevaluate the performance concern. Co-authored-by: sternenseemann <sternenseemann@systemli.org>
Diffstat (limited to 'pkgs/development/haskell-modules/generic-builder.nix')
-rw-r--r-- | pkgs/development/haskell-modules/generic-builder.nix | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index e76f5012f95..d8137038f63 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -56,6 +56,7 @@ in , mainProgram ? null , doCoverage ? false , doHaddock ? !(ghc.isHaLVM or false) +, doHaddockInterfaces ? doHaddock && lib.versionAtLeast ghc.version "9.0.1" , passthru ? {} , pkg-configDepends ? [], libraryPkgconfigDepends ? [], executablePkgconfigDepends ? [], testPkgconfigDepends ? [], benchmarkPkgconfigDepends ? [] , testDepends ? [], testHaskellDepends ? [], testSystemDepends ? [], testFrameworkDepends ? [] @@ -226,7 +227,11 @@ let ] ++ optionals isCross ([ "--configure-option=--host=${stdenv.hostPlatform.config}" ] ++ crossCabalFlags - ) ++ optionals enableSeparateBinOutput ["--bindir=${binDir}"]; + ) ++ optionals enableSeparateBinOutput [ + "--bindir=${binDir}" + ] ++ optionals (doHaddockInterfaces && isLibrary) [ + "--ghc-options=-haddock" + ]; setupCompileFlags = [ (optionalString (!coreSetup) "-${nativePackageDbFlag}=$setupPackageConfDir") |