nixpkgs icon indicating copy to clipboard operation
nixpkgs copied to clipboard

environment.shellAliases not honored for `ls`

Open mfiano opened this issue 8 years ago • 6 comments

Issue description

Defining a shell alias using config.environment.shellAliases for the ls command is not honored, due to this being defined afterwards: https://github.com/NixOS/nixpkgs/blob/56904d7c423f2b13b37fbd29f39bbb4b52bc7824/nixos/modules/programs/shell.nix#L17-L21

Steps to reproduce

Try overriding config.environment.shellAliases = { ls = "..." };

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.9.84, NixOS, 18.03pre130151.268d99b1fe4 (Impala)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 1.11.16
  • channels(root): "nixos-18.03pre130151.268d99b1fe4"
  • channels(mfiano): "nixos-17.09-17.09.3101.fd1d76bb1a8"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs

mfiano avatar Mar 04 '18 07:03 mfiano

Are you sure? I have the following working as expected on nixos-17.09 and nixos-unstable with bash and zsh.

config.environment.shellAliases = { ls = "ls --color=tty -F" };

yesbox avatar Mar 04 '18 14:03 yesbox

Yes, I'm sure. I have a pile of aliases defined in config.environment.shellAliases, and ls is the only one that is not correct -- it's exactly what is defined in the above link.

mfiano avatar Mar 04 '18 16:03 mfiano

If you use zsh, then environment.shellAliases is not used, you have to add it yourself which is counterintuitive IMO.

teto avatar Mar 05 '18 03:03 teto

This is bash, and all of my environment.shellAliases are being used except the one for ls is instead aliased to be that of the above link in the nixpkgs source.

mfiano avatar Mar 05 '18 07:03 mfiano

That's because shellAliases are defined as attrs

https://github.com/NixOS/nixpkgs/blob/7e40287d00e39bed522c59da805d20c298699411/nixos/modules/programs/bash/bash.nix#L64

And merge function for attrs type replaces configuration attributes with default:

https://github.com/NixOS/nixpkgs/blob/7e40287d00e39bed522c59da805d20c298699411/lib/types.nix#L149

Merge function should work the other way round - replace default values with configuration

danbst avatar Mar 06 '18 16:03 danbst

Solved with https://github.com/NixOS/nixpkgs/pull/44441

infinisil avatar Oct 13 '18 15:10 infinisil