reddit / emacs

Emacs + emacs-direnv + Nix + vterm does not just work

lompocus · 2022-12-28 00:00
So I want direnv to automatically do its direnv thing whenever I open a vterm. Let us say I have: 1. Configured direnv and my .bashrc as normal. 2. Configured nix-direnv on NixOS by modifying configuration.nix as normal. 3. Configured emacs' configuration for emacs-direnv as normal. Now consider I have: 1. Make some directory /tmp/xyz, made a shell.nix or flake.nix file, and done either `echo "use nix" >> .envrc && direnv allow` or `echo "use flake" >> .envrc && direnv allow` as appropriate. Then, every time I open a file, emacs-direnv direnvs in its direnv way, successfully, much to my happiness. I vterm and cd to my file and direnv also direnvs successfully. Let us now say I do M-x cd /tmp/xyz, wherein I have stored some .envrc and shell.nix (or flake.nix or whatever) files. Opening a file direnvs successfully. However, opening a vterm sometimes does nothing, whereupon I must first cd out of my directory and cd back into my directory. For some reason this happens inconsistently. Does anyone else have this problem? It seems only to occur with flake.nix files and not shell.nix files.
what-the-functor · 2022-12-28 00:16
I don't use flake.nix, only shell.nix, though check if the envrc package works any better for you. https://github.com/purcell/envrc
lompocus · 2022-12-28 00:50
Well, come to think of it, neither emacs-direnv nor emacs-envrc should matter with regard to vterm; and in any case I'm not running into the problem anymore. However, envrc looks to be much better than direnv, thank, I'm using that now.
Psionikus · 2022-12-28 01:57
Does your bashrc configuration lead to the direnv hook being evaluated? eval "$(direnv hook bash)" echo $PROMPT_COMMAND should show you _direnv_hook
NotFromSkane · 2022-12-28 02:51
I'm using the emacs overlay documented on the wiki. Direnv doesn't work with the emacsLsp package based on 28, but it does with emacsGit. I am pinned to mid November though
[deleted] · 2022-12-28 20:59
[deleted]