Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redo: add doc to ghc wrapper #77523

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkgs/development/haskell-modules/with-packages-wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ symlinkJoin {
# as a dedicated drv attribute, like `compiler-name`
name = ghc.name + "-with-packages";
paths = paths ++ [ghc];
extraOutputsToInstall = ["doc"];
allowCollisions = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignoring all file collisions in the ghc-wrapper feels like a hack. I'd rather not do this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's due to buildEnv propagating the dependencies. Not sure how to turn that off. I'd actually prefer to set allowCollisions here regardless because that is what symlinkJoin does by default.

For instance, compare:

{ pkgs ? import <nixpkgs> {} }:

pkgs.symlinkJoin {
  name = "test";
  paths = [
    (pkgs.writeTextDir "/share/doc/uuid-types-1.0.3/html/uuid-types.haddock" "a")
    (pkgs.writeTextDir "/share/doc/uuid-types-1.0.3/html/uuid-types.haddock" "b")
  ];
}

vs.

{ pkgs ? import <nixpkgs> {} }:

pkgs.buildEnv {
  name = "test";
  paths = [
    (pkgs.writeTextDir "/share/doc/uuid-types-1.0.3/html/uuid-types.haddock" "a")
    (pkgs.writeTextDir "/share/doc/uuid-types-1.0.3/html/uuid-types.haddock" "b")
  ];
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to treat collisions as an error. Because they usually are.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to avoid the regression then. The two packages given in the revert (cabal-plan & aeson), depend on two different versions of uuid-types:

$ nix-store -qR $(nix-build '<nixpkgs>' -A haskellPackages.cabal-plan) | grep uuid-types
/nix/store/vs6xvan33d5jmhaybwkddmdfljigm050-uuid-types-1.0.3-doc
/nix/store/pv27lwjz900idmyrf0hykhfr95a2yk44-uuid-types-1.0.3
$ nix-store -qR $(nix-build '<nixpkgs>' -A haskellPackages.aeson) | grep uuid-types
/nix/store/s9babnwzfpq4vj02p20070pxfc6zpilx-uuid-types-1.0.3-doc
/nix/store/ciqb2va7qbhzb0b0s5ak289pnks3bfvd-uuid-types-1.0.3

We could just add map (lib.getOutput "doc") to the symlinkJoin, if that seems better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how to remedy that issue. My problem with the "simple solution" is this: If different versions of a package exist, then these versions differ in the set of dependencies they link or flags they've been compiled with or something like that. Arguably, those differences may very well manifest in the API and in the generated documentation, so I would assume that those foobar.haddock files might differ, too. Ignoring collisions means that we'll just pick a random one and link it into the generated store path. But that doesn't feel right. The foobar.haddock file you'll get should be bundled in some obvious way with the library that it belongs to. This means that doc hierarchy might need $out baked into its directory name, maybe? Then there would be no more file collisions, because the *.haddock files would no longer be ambiguous. Does that make sense?

postBuild = ''
. ${makeWrapper}/nix-support/setup-hook

Expand Down