Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Supporting Nix. #120

Closed
kazu-yamamoto opened this issue Apr 19, 2013 · 8 comments
Closed

Supporting Nix. #120

kazu-yamamoto opened this issue Apr 19, 2013 · 8 comments

Comments

@kazu-yamamoto
Copy link
Collaborator

ghc-mod does not work on Nix.

https://gist.github.com/dysinger/5379845

@kazu-yamamoto
Copy link
Collaborator Author

@dysinger @kosmikus You may want to join this ticket.

@kazu-yamamoto
Copy link
Collaborator Author

This issue may be relating to: NixOS/nixpkgs#213

@kosmikus
Copy link

Sorry for not replying earlier. I'm aware that the current solution in Nix is not optimal, but ghc-mod seems to work for me if I set the NIX_GHC and NIX_GHC_LIBDIR variables properly. Note that ghc-mod is a part of Nixpkgs, so you should preferably not install it via cabal-install, but via Nix itself.

@dysinger
Copy link
Contributor

dysinger commented May 2, 2013

I have ghc-mod installed with nix & it wasn't working for me (which is why I talked to @kazu-yamamoto). @kosmikus what do you have NIX_GHC & NIX_GHC_LIBDIR set to ? where can I get more docs/info?

@kosmikus
Copy link

kosmikus commented May 2, 2013

These env-vars are not really documented. There's some discussion in NixOS/nixpkgs#213 that Kazu had listed above. We're not sure that this is the "right" solution, but I can't seem to think of a much better one right now.

Regarding my configuration. I have a GHC environment using GHC and other packages in my nixpkgs.config, roughly as follows:

pkgs : {
  packageOverrides = pkgs : rec {
    myHaskellPackages = {
      all = pkgs.haskellPackages.ghcWithPackages (self : [
        self.ghcMod
        self.unorderedContainers
        # ... and lots of other Haskell packages I use
      ]);
    };
  };
}

I then install myHaskellPackages to a specific profile (in my case to something like $HOME/profiles/myHaskell). One can install it into the default profile, too, but I'm using multiple different GHC configurations ...

I ensure the ghc-mod is in the PATH and the emacs installation works. However, in this state, ghc-mod will not see the other Haskell packages in the environment:

$ ghc-mod browse Data.HashMap.Strict
Dummy:0:0:Error:Could not find module `Data.HashMap.Strict'
Perhaps you meant
  Data.IntMap.Strict (from containers-0.5.0.0)
  Data.Map.Strict (from containers-0.5.0.0)
Use -v to see a list of the files searched for.

However, with

export NIX_GHC_LIBDIR="$HOME/profiles/myHaskell/lib"

I get

$ ghc-mod browse Data.HashMap.Strict
HashMap
adjust
delete
...

If you have multiple profiles containing different GHCs, it's not necessary that the ghc-mod is in the same profile as the one that NIX_GHC_LIBDIR points to.

@dysinger
Copy link
Contributor

dysinger commented May 5, 2013

Awesome. I have the same setup except mine's called haskellEnv instead of myHaskell.

@peti
Copy link
Contributor

peti commented Apr 4, 2014

ghc-mod should work fine with Nix these days.

Users of 'ghcWithPackages' might want to add the following snippet to
their ~/.bashrc, too:

NIX_GHC=$(type -p ghc)
if [ -n "$NIX_GHC" ]; then
  eval $(grep export "$NIX_GHC")
fi

@kazu-yamamoto
Copy link
Collaborator Author

Nice!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants