tweag / cooked-validators

MIT License
39 stars 11 forks source link

Prompt for nix develop #229

Closed mmontin closed 1 year ago

mmontin commented 1 year ago

Could we have a specific prompt withing our nix develop environment? Would make it easier to see whether we're in or out of it.

carlhammann commented 1 year ago

Yes, that's possible using something like

nixConfig.bash-prompt-suffix = "Now you are in the devshell ";

in the flake.

gabrielhdt commented 1 year ago

I'd advocate towards not using this parameter in the flake because it is intrusive. Some people have their own prompt configuration and do not want the flake to mess with it.

I think you can edit your nix.conf file to change your prompt upon entering a nix develop environment https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-develop.html#description (and furthermore, this will work for all flakes, not only the one with the option activated.

Niols commented 1 year ago

I'd advocate towards not using this parameter in the flake because it is intrusive.

Exactly the same; it's usually not appreciated to force a prompt upon people. Basically anything that a flake does through nixConfig. you should be careful because it can mess up with the user's configuration. That also means a user can achieve the same effect for themselves easily, which will also lead to more consistency when working on different Nix projects. For instance, my prompt always shows me Nix environments automatically:

image

mmontin commented 1 year ago

I do understand this concern, although each and every client project we handle makes it fairly explicit when entering the nix env. In our old cooked conf, if was pretty visible as well when entering a nix-shell. So why do all clients do that if that's bad practice (it's a genuine question)?

gabrielhdt commented 1 year ago

It was visible in the old configuration because nix-shell was used, which changed the prompt by default, if I'm correct.

For your second question, I think it's a matter of mindset, perhaps local culture, and mostly awareness.

mmontin commented 1 year ago

Thanks, you've convinced me it was not needed by default, and @florentc helped me in having a custom prompt to showcase it.