about summary refs log tree commit diff
path: root/pkgs/development/haskell-modules
diff options
context:
space:
mode:
authorsternenseemann <sternenseemann@systemli.org>2021-12-16 09:13:30 -0400
committersternenseemann <sternenseemann@systemli.org>2023-01-15 17:35:42 +0100
commit727491cd957632ae9dc0449f3600999b40a8a61a (patch)
tree350f7b2428790fd5446b9a0e5eab04bacf7cd8b0 /pkgs/development/haskell-modules
parent02cbec616aa7b7cafe3b76a39031c0c74c07106a (diff)
downloadnixlib-727491cd957632ae9dc0449f3600999b40a8a61a.tar
nixlib-727491cd957632ae9dc0449f3600999b40a8a61a.tar.gz
nixlib-727491cd957632ae9dc0449f3600999b40a8a61a.tar.bz2
nixlib-727491cd957632ae9dc0449f3600999b40a8a61a.tar.lz
nixlib-727491cd957632ae9dc0449f3600999b40a8a61a.tar.xz
nixlib-727491cd957632ae9dc0449f3600999b40a8a61a.tar.zst
nixlib-727491cd957632ae9dc0449f3600999b40a8a61a.zip
ghc.withPackages: install documentation to -with-packages output
* Will make it so that GHC.Paths's docdir NIX_GHC_DOCDIR points to an
  actual directory.

* Documentation of all packages in the environment is available in
  `$out/share/doc`.

This has previously been attempted in #76842 and reverted in #77442,
since documentation can collide when the libraries wouldn't (thanks to
the hash in the lib filename). `symlinkJoin` allows collision, so this
solution should be akin to #77523 (minus `buildEnv`, one step at a
time). `installDocumentation = false` restores the old behavior.

Collision in the documentation only happen if the dependency closure of
the given packages has more than one different derivation for the same
library of the very same version. I'm personally inclined not to claim
that our infrastructure does anything sensible in this case.
Additionally, the documentation is likely largely the same in such
cases (unless it is heavily patched).

Resolves #150666.
Resolves #76837.
Closes #150968.
Closes #77523.
Diffstat (limited to 'pkgs/development/haskell-modules')
-rw-r--r--pkgs/development/haskell-modules/with-packages-wrapper.nix12
1 files changed, 10 insertions, 2 deletions
diff --git a/pkgs/development/haskell-modules/with-packages-wrapper.nix b/pkgs/development/haskell-modules/with-packages-wrapper.nix
index c478c875540d..acb9156b0a7e 100644
--- a/pkgs/development/haskell-modules/with-packages-wrapper.nix
+++ b/pkgs/development/haskell-modules/with-packages-wrapper.nix
@@ -4,6 +4,8 @@
 # platform that has NCG support
 , useLLVM ? false
 , withHoogle ? false
+# Whether to install `doc` outputs for GHC and all included libraries.
+, installDocumentation ? true
 , hoogleWithPackages
 , postBuild ? ""
 , ghcLibdir ? null # only used by ghcjs, when resolving plugins
@@ -54,7 +56,11 @@ let
                   else "$out/lib/${ghc.targetPrefix}${ghc.haskellCompilerName}";
   docDir        = "$out/share/doc/ghc/html";
   packageCfgDir = "${libDir}/package.conf.d";
-  paths         = lib.filter (x: x ? isHaskellLibrary) (lib.closePropagation packages);
+  paths         = lib.concatLists (
+                    builtins.map
+                      (pkg: [ pkg ] ++ lib.optionals installDocumentation [ (lib.getOutput "doc" pkg) ])
+                      (lib.filter (x: x ? isHaskellLibrary) (lib.closePropagation packages))
+                  );
   hasLibraries  = lib.any (x: x.isHaskellLibrary) paths;
   # CLang is needed on Darwin for -fllvm to work:
   # https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
@@ -71,7 +77,9 @@ symlinkJoin {
   # if such a feature is needed, the real compiler name should be saved
   # as a dedicated drv attribute, like `compiler-name`
   name = ghc.name + "-with-packages";
-  paths = paths ++ [ghc];
+  paths = paths
+          ++ [ ghc ]
+          ++ lib.optionals installDocumentation [ ghc.doc ];
   nativeBuildInputs = [ makeWrapper ];
   postBuild = ''
     # wrap compiler executables with correct env variables