Skip to content

Commit

Permalink
ghc.withPackages: install documentation to -with-packages output
Browse files Browse the repository at this point in the history
* 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 NixOS#76842 and reverted in NixOS#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 NixOS#77523 (minus `buildEnv`, one step at a
time).

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 NixOS#150666.
Resolves NixOS#76837.
Closes NixOS#150968.
Closes NixOS#77523.
  • Loading branch information
sternenseemann committed Jan 14, 2023
1 parent 02cbec6 commit 9733590
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkgs/development/haskell-modules/with-packages-wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# platform that has NCG support
, useLLVM ? false
, withHoogle ? false
, installDocs ? true
, hoogleWithPackages
, postBuild ? ""
, ghcLibdir ? null # only used by ghcjs, when resolving plugins
Expand Down Expand Up @@ -54,7 +55,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 installDocs [ (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
Expand All @@ -71,7 +76,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 installDocs [ ghc.doc ];
nativeBuildInputs = [ makeWrapper ];
postBuild = ''
# wrap compiler executables with correct env variables
Expand Down

0 comments on commit 9733590

Please sign in to comment.