glacambre / firenvim

Embed Neovim in Chrome, Firefox & others.
GNU General Public License v3.0
4.69k stars 145 forks source link

Remove nixos store paths from .local/share/firenvim/firenvim #1459

Closed SuperSandro2000 closed 1 year ago

SuperSandro2000 commented 1 year ago

Install firenvim.

What happened

The ~/.local/share/firenvim/firenvim script contains store paths which get eventually garbage collected when the system changes enough.

The following PATH elements are problematic:

nodejs and ctags are always in the PATH through the nvim wrapper which lives at /etc/profiles/per-user/sandro/bin/nvim. Why does PATH need to be exported here?

I need to investigate why XDG_DATA_DIRS contains /nix/store/rhqd7ir7c9fnqh5a7mb82v1wbgc2wv3b-desktops/share and is not linked under /run/current-system.

Full contents of the file:

#!/bin/sh
mkdir -p /tmp//firenvim
chmod 700 /tmp//firenvim
cd /tmp//firenvim
export PATH="$PATH:/run/wrappers/bin:/home/sandro/.nix-profile/bin:/etc/profiles/per-user/sandro/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/nix/store/02wg7ljy43i8r2vh2nl3kpv7i4xnswrd-nodejs-18.10.0/bin:/nix/store/9cd56ybj4mk4afjsbvpqg8vhlrm8ndv2-universal-ctags-5.9.20220814.0/bin"
unset NVIM_LISTEN_ADDRESS
if [ -n "$VIM" ] && [ ! -d "$VIM" ]; then
  unset VIM
fi
if [ -n "$VIMRUNTIME" ] && [ ! -d "$VIMRUNTIME" ]; then
  unset VIMRUNTIME
fi
if [ ! -n "$XDG_DATA_HOME" ]; then
  XDG_DATA_HOME='/home/sandro/.local/share'
  export XDG_DATA_HOME
fi
if [ ! -n "$XDG_CONFIG_HOME" ]; then
  XDG_CONFIG_HOME='/home/sandro/.config'
  export XDG_CONFIG_HOME
fi
if [ ! -n "$XDG_STATE_HOME" ]; then
  XDG_STATE_HOME='/home/sandro/.local/state'
  export XDG_STATE_HOME
fi
if [ ! -n "$XDG_DATA_DIRS" ]; then
  XDG_DATA_DIRS='/nix/store/rhqd7ir7c9fnqh5a7mb82v1wbgc2wv3b-desktops/share:/home/sandro/.nix-profile/share:/etc/profiles/per-user/sandro/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share'
  export XDG_DATA_DIRS
fi
if [ ! -n "$XDG_CONFIG_DIRS" ]; then
  XDG_CONFIG_DIRS='/etc/xdg:/home/sandro/.nix-profile/etc/xdg:/etc/profiles/per-user/sandro/etc/xdg:/nix/var/nix/profiles/default/etc/xdg:/run/current-system/sw/etc/xdg'
  export XDG_CONFIG_DIRS
fi
if [ ! -n "$XDG_CACHE_HOME" ]; then
  XDG_CACHE_HOME='/home/sandro/.cache'
  export XDG_CACHE_HOME
fi

exec '/etc/profiles/per-user/sandro/bin/nvim' --headless --cmd "let g:firenvim_i=[]|let g:firenvim_o=[]|let g:Firenvim_oi={i,d,e->add(g:firenvim_i,d)}|let g:Firenvim_oo={t->add(g:firenvim_o,t)}|let g:firenvim_c=stdioopen({'on_stdin':{i,d,e->g:Firenvim_oi(i,d,e)},'on_print':{t->g:Firenvim_oo(t)}})" --cmd 'let g:started_by_firenvim = v:true' -c 'try|call firenvim#run()|catch|call chansend(g:firenvim_c,["f\n\n\n"..json_encode({"messages":["Your plugin manager did not load the Firenvim plugin for neovim."]+g:firenvim_o,"version":"0.0.0"})])|call chansend(2,["Firenvim not in rtp:"..&rtp])|qall!|endtry'
glacambre commented 1 year ago

The following PATH elements are problematic:

Having non-existing directories in your $PATH is not a problem.

Why does PATH need to be exported here?

Because Firenvim users sometimes launch their browsers in a way that results in the environment variables that they rely on in their Neovim config not being set. For example, I've been told that GDM's most recent versions do not load /etc/profile. Another example is people setting their $PATH in their .bashrc/.zshrc.

I need to investigate why XDG_DATA_DIRS contains /nix/store/rhqd7ir7c9fnqh5a7mb82v1wbgc2wv3b-desktops/share

That's because XDG_DATA_DIRS contained this value when you ran firenvim#install(). I'm not familiar with nix, but perhaps you were in a specific nix shell/nix env that set this variable?

glacambre commented 1 year ago

I don't think there's anything I can/should do here.

SuperSandro2000 commented 1 year ago

Having non-existing directories in your $PATH is not a problem.

Yes but the nix store paths change when updating the system and if neovim requires them they no longer work but the wrapper should append the right paths anyway. Worst case I just need to regenerate this file when updating which wouldn't be a problem.