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

"With-packages" wrapper for GHC does not wrap Haddock #36976

Closed
mrkkrp opened this issue Mar 14, 2018 · 7 comments
Closed

"With-packages" wrapper for GHC does not wrap Haddock #36976

mrkkrp opened this issue Mar 14, 2018 · 7 comments

Comments

@mrkkrp
Copy link
Member

mrkkrp commented Mar 14, 2018

Issue description

We use haskell.packages.ghc822.ghcWithPackages which allows to add some packages to GHC installation so they are always visible. This works with ghc, ghci, ghc-pkg, but does not work for haddock because it's not wrapped, and so non-built-in packages are not visible to it.

Steps to reproduce

Put the following in a file called haddock-not-wrapped.nix:

let nixpkgs = import <nixpkgs> {};
in

nixpkgs.buildEnv {
  name = "my-thing";
  paths = with nixpkgs; [
    (haskell.packages.ghc822.ghcWithPackages (p: with p; [
      base
      binary
      binary-orphans
    ]))
    bash
  ];
}

Then execute:

$ nix-env -if haddock-not-wrapped.nix
$ which haddock
/root/.nix-profile/bin/haddock
$ haddock --optghc -package --optghc base
$ echo $?
0
$ haddock --optghc -package --optghc binary-orphans
<command line>: cannot satisfy -package binary-orphans
    (use -v for more information)
$ echo $?
1

Technical details

Please run nix-shell -p nix-info --run "nix-info -m" and paste the
results.

 - system: `"x86_64-linux"`
 - host os: `Linux 4.15.8-1-ARCH, Alpine Linux, noversion`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 1.11.14`
 - channels(root): `"nixpkgs-18.03pre128481.1098c071e59"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs
@srhb
Copy link
Contributor

srhb commented Mar 14, 2018

The slightly unfortunately named ghcWithHoogle also wraps haddocks up nicely. However, from your test case, I'm really not sure what problem you're trying to alleviate exactly. Could you describe what you're trying to achieve?

@mrkkrp
Copy link
Member Author

mrkkrp commented Mar 15, 2018

Well, haddock should be able to see these packages like other tools (ghc, ghc-pkg) do.

@srhb
Copy link
Contributor

srhb commented Mar 15, 2018

Oh, I see, the resulting haddock is just a symlink to the generic (ghc-8.2) haddock, which does not point its -B flag at the combined set from ghcWithPackages. I wonder how difficult that would be to fix...

@srhb
Copy link
Contributor

srhb commented Mar 15, 2018

Conceptually, I think it's something like this...

export gwh=$(nix-build --no-out-link -E 'with import <nixpkgs> {}; haskellPackages.ghcWithHoogle (hps: with hps; [ binary binary-orphans  ])')

$gwh/bin/haddock -B $gwh/lib/ghc-* --optghc -package --optghc binary-orphans
echo $?

and the haddock wrapper in $gwh could just have that -B as its default.

@srhb
Copy link
Contributor

srhb commented Mar 15, 2018

Looks like it might be as simple as adding haddock to the loop in https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/haskell-modules/with-packages-wrapper.nix#L64

Or at least something very similar that sets -B correctly.

@srhb
Copy link
Contributor

srhb commented Mar 19, 2018

@mrkkrp Does this fix your issue? :)

@srhb
Copy link
Contributor

srhb commented Mar 21, 2018

Please reopen if this is still a problem. :)

@srhb srhb closed this as completed Mar 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants