Hi guys, I recently took the leap into Nix flakes by converting my /etc/nixos directory to use one, and I also turned my old shell.nix which I used for development into a flake.nix.
However, I’m having a breaking issue with Tmux, which I use regularly during development. It only happens when using flake.nix + nix develop; I don’t get the same issue using nix-shell.
Specifically what’s happening is that any escaped character in my PS1 prompt seems to break inside of Tmux, displaying the \ escape characters. This would be annoying if it were only cosmetic, however it seems that some of the escaped characters are forming command sequences, which leads to lots of inputs becoming corrupted at the command line: for example, I can’t use the cursor keys to move up and down in the history, it instead just generates junk keycodes.
Here’s an example of what’s happening:
Normal prompt :
~/test via ❄️ impure (nix-shell-env)
❯
In tmux:
\[\]~/test\[\] via \[\]❄️ impure (nix-shell-env)\[\]
\[\]❯\[\]
I’ve done extensive testing and this happens with Starship (used in the example) as well as more basic PS1 prompts, including the nixOS default of
\n\[\033[$PROMPT_COLOR\][\u@\h:\w]\\$\[\033[0m\]
. If I use a simple plaintext prompt with no escape sequences, it works fine, but I would prefer to not be limited to uncolored plaintext prompts.
Again, this never happened while using nix-shell. It seems to happen any time I use nix develop, even with a completely bare-bones flake.nix that has no additional packages or shell hooks.
echo $PS1 gives the same results inside and outside of tmux (and the flake).
I’m at a loss for how to debug or fix this. I’m on the verge of going back to nix-shell because of this single issue, which currently breaks my workflow. Any help would be greatly appreciated.