nix-darwin icon indicating copy to clipboard operation
nix-darwin copied to clipboard

Environment shell aliases

Open alecandido opened this issue 5 months ago • 2 comments

The content of environment.shellAliases is treated in a (at least) inconsistent way.

For Bash, it ends up in /etc/bashrc: https://github.com/LnL7/nix-darwin/blob/bbde06bed1b72eddff063fa42f18644e90a0121e/modules/programs/bash/default.nix#L48-L71 while for ZSH, it's put in /etc/zprofile: https://github.com/LnL7/nix-darwin/blob/bbde06bed1b72eddff063fa42f18644e90a0121e/modules/programs/zsh/default.nix#L146-L155 (for both, only first and last lines are relevant)

Personally, I spend most of the time in a non-login shell, so it is a bit annoying to not have aliases defined there. However, I'm not sure what is the most suitable recommendation, and whether you could abuse(?) zshenv for this purpose. But I'm pretty sure it would make sense to have it consistent on the two shells.

alecandido avatar Feb 26 '24 11:02 alecandido

Btw, in NixOS the aliases are actually set in /etc/zshrc.

https://github.com/NixOS/nixpkgs/blob/fcea2b6260dd566c28c894b4207a5f2b56c2cba3/nixos/modules/programs/zsh/zsh.nix#L279-L280

alecandido avatar Feb 26 '24 17:02 alecandido

Note that Home-Manager also sets aliases in the user's zshrc: https://github.com/nix-community/home-manager/blob/bfa7c06436771e3a0c666ccc6ee01e815d4c33aa/modules/programs/zsh.nix#L666

Personally, this caused quite a bit of confusion for me since Zellij seems to launch shells as interactive, non-login shells, so Home-Manager defined aliases worked as expected but Nix-Darwin defined aliases did not.

I think it makes semantically more sense to put aliases in zshrc, and that would bring consistency with NixOS and Home-Manager as well.

madsbv avatar Apr 24 '24 10:04 madsbv