I’ve just started using IHP (with ihp-new
), and I’m having some trouble getting the editor integration working in emacs. I’m using lsp-mode rather than eglot (which I would prefer not to change), and I can’t get it to integrate with nix correctly.
Whether I use direnv-mode
or envrc-mode
, though I can see that the environment is being applied, lsp-mode can’t seem to find haskell-language-server-wrapper
, instead echoing the following in the minibuffer:
LSP :: The following servers support current file but do not have automatic installation: lsp-haskell
You may find the installation instructions at Languages - LSP Mode - LSP support for Emacs.
(If you have already installed the server check lsp-log).
(Unfortunately, there’s no output at all in lsp-log from this invocation of lsp.)
On non-flake nix projects, I normally set lsp-haskell-server-wrapper-function
to call nix-shell
to find the language server:
(setq lsp-haskell-server-wrapper-function
(lambda (argv)
(append
(append (list "nix-shell" "-I" "." "--command" )
(list (mapconcat 'identity argv " ")))
(list "shell.nix"))))
That doesn’t work in my IHP project because there isn’t a shell.nix
. (I haven’t really used flakes before, so I might be missing something here.)
I tried using nix develop
instead (with and without --impure
, which made no difference):
(setq lsp-haskell-server-wrapper-function
(lambda (argv)
(append
(append (list "nix" "develop" "--impure" "--command" )
(list (mapconcat 'identity argv " "))))))
…this gives me a devenv error message:
warning: Git tree '/Users/Emily/Work/Pannal Village Hall (no git)/ihp-alternative' is dirty
error:
… while evaluating the attribute 'optionalValue.value'
at /nix/store/sc2fmza4wlzi16jjjmkg6rmmmf75jxmr-source/lib/modules.nix:856:5:
855|
856| optionalValue =
| ^
857| if isDefined then { value = mergedValue; }
… while evaluating a branch condition
at /nix/store/sc2fmza4wlzi16jjjmkg6rmmmf75jxmr-source/lib/modules.nix:857:7:
856| optionalValue =
857| if isDefined then { value = mergedValue; }
| ^
858| else {};
(stack trace truncated; use '--show-trace' to show the full trace)
error: Failed assertions:
- devenv was not able to determine the current directory.
See https://devenv.sh/guides/using-with-flakes/ how to use it with flakes.
I’ve tried the devenv link, but nothing there seems helpful for this specific situation, and googling hasn’t got me anywhere either.
Any ideas for what I can do to get either the direnv support or the more manual wrapping working correctly?