1) Install Kakoune via nix
2) Install dash via nix
3) Set KAKOUNE_POSIX_SHELL="${pkgs.dash}/bin/dash"
4) Start kakoune
5) run echo %sh{ echo $KAKOUNE_POSIX_SHELL }
6) run echo %sh { echo $0 }
/nix/store/g7hpqj8nfhx3c81zr99wlqfih7l922ma-dash-0.5.10.2/bin/dash
sh
/nix/store/g7hpqj8nfhx3c81zr99wlqfih7l922ma-dash-0.5.10.2/bin/dash
/nix/store/g7hpqj8nfhx3c81zr99wlqfih7l922ma-dash-0.5.10.2/bin/dash
I'm trying to do this because NixOS symlinks /bin/sh to bash, which means it is way slower to startup (1/2s) on NixOS compared to my install on another computer (0.1s). I'm fairly new to kakoune so this could absolutely be something I'm doing wrong
Thanks for all your hard work!
Edit: fixed the outcome
Looking at how Kakoune handles that environment variable, it looks like if the shell doesn't exist or isn't executable, Kakoune will immediately crash, rather than starting up normally:
$ KAKOUNE_POSIX_SHELL=/does/not/exist kak
Fatal error: KAKOUNE_POSIX_SHELL '/does/not/exist' is not executable
Where and how are you setting this variable?
I'm using home-manager to set it via my NixOS configuration, which is why I can access the exact location of the package in the store using ${pkgs.dash}. If it would help my nix-config is public.
I realized that I had reproduced the outcome incorrectly however, in reality it produces the following from echo %sh { echo $0 }:
sh
I'm not sure how to confirm if it is indeed running dash or bash, it just seems really slow on my NixOS install to startup which didn't seem to improve any after adding the environment variable. It's not a big deal, just was wondering if I was doing something wrong or expecting too much from swapping to dash
I guess the most basic test would be: in a terminal, where you would normally run kak, try running $KAKOUNE_POSIX_SHELL instead. If you get some kind of "file not found" error, that's a good thing to know. Otherwise, if you get a bare $ prompt, it's probably dash, and if you get your regular bash prompt, or something like sh-5.0$, it's probably bash. To be completely sure, you can try a bash-specific command like fc and see if it's recognised.
Running $KAKOUNE_POSIX_SHELL does successfully open up dash, and running echo %sh{ sh -c 'ps -p $$ -o ppid=' | xargs ps -o comm= -p } inside kakoune also seems to print dash, so it looks like it is working as expected. Sorry to bother!
Most helpful comment
I guess the most basic test would be: in a terminal, where you would normally run
kak, try running$KAKOUNE_POSIX_SHELLinstead. If you get some kind of "file not found" error, that's a good thing to know. Otherwise, if you get a bare$prompt, it's probably dash, and if you get your regular bash prompt, or something likesh-5.0$, it's probably bash. To be completely sure, you can try a bash-specific command likefcand see if it's recognised.