with this shell.nix: https://dpaste.org/NcYb , when i run nix-shell in terminal, emacs opens up into the directory and ghcide is able to recognize modules when i try to import, but when i try to use (lorri+direnv+emacs-direnv) in emacs, ghcide works but it's not able to recognize modules, like when i try to import Yesod for example.
So it works from a Nix shell, but doesn't otherwise? Is the cause that direnv isn't replicating the Nix shell properly? I have no idea how you'd test that.
I am using ghcide in roughly that setup(vscode instead of emacs). I use the nix-shell to set up the environment and ghcide is on my path. That setup works great for me.
I've had some success getting (lorri+direnv+emacs-direnv) in emacs to work. Can you share the relevant bits of your Emacs config and that shell.nix again (link is broken)?
it turns out that i was missing the lorri shell command, now ghcide is able to pick up on shell.nix's environment variables placed in shellHook, also, when setting up ihaskell, i needed to place use_nix shell.nix inside of .envrc in order for it to work, just thought i'd share that piece of information as well.
other than a few edge cases that i need to figure out, everything seems to be working now, thanks for the help everyone.
go ahead and close this issue.
and apologies, dpaste deletes pastebin's after a certain amount of time, here's the shell.nix that i am currently using for haskell development:
let
pkgs = import
in
with pkgs;
mkShell
{
buildInputs = with pkgs;
[
(haskell.packages.ghc883.ghcWithHoogle (hpkgs: with hpkgs;
[
ghcid
cabal-install
]))
# ghcide-nix installation:
(import (builtins.fetchTarball "https://github.com/cachix/ghcide-nix/tarball/master") {}).ghcide-ghc883
]; # end of buildInputs
shellHook =
''
export EDITOR=emacs;
export HIE_HOOGLE_DATABASE="$(cat $(which hoogle) | sed -n -e 's|.*--database \\(.*\\.hoo\\).*|\\1|p')";
export NIX_GHC="$(which ghc)";
export NIX_GHCPKG="$(which ghc-pkg)";
export NIX_GHC_DOCDIR="$NIX_GHC/../../share/doc/ghc/html";
export NIX_GHC_LIBDIR="$(ghc --print-libdir)";
'';
} # end of mkShell
Had been some improvements for use ghcide in nix environments, @zeta-00 could you check if you continue experiencing the issue with lastest ghcide?
Most helpful comment
it turns out that i was missing the
lorri shellcommand, nowghcideis able to pick up on shell.nix's environment variables placed in shellHook, also, when setting upihaskell, i needed to placeuse_nix shell.nixinside of .envrc in order for it to work, just thought i'd share that piece of information as well.other than a few edge cases that i need to figure out, everything seems to be working now, thanks for the help everyone.
go ahead and close this issue.