Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

environment.shellAliases not honored for ls #36282

Closed
mfiano opened this issue Mar 4, 2018 · 6 comments
Closed

environment.shellAliases not honored for ls #36282

mfiano opened this issue Mar 4, 2018 · 6 comments

Comments

@mfiano
Copy link

mfiano commented Mar 4, 2018

Issue description

Defining a shell alias using config.environment.shellAliases for the ls command is not honored, due to this being defined afterwards:

environment.shellAliases =
{ ls = "ls --color=tty";
ll = "ls -l";
l = "ls -alh";
};

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
@yesbox
Copy link
Contributor

yesbox commented Mar 4, 2018

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" };

@mfiano
Copy link
Author

mfiano commented Mar 4, 2018

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.

@teto
Copy link
Member

teto commented Mar 5, 2018

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

@mfiano
Copy link
Author

mfiano commented Mar 5, 2018

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.

@danbst
Copy link
Contributor

danbst commented Mar 6, 2018

That's because shellAliases are defined as attrs

type = types.attrs; # types.attrsOf types.stringOrPath;

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

merge = loc: foldl' (res: def: mergeAttrs res def.value) {};

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

@infinisil
Copy link
Member

Solved with #44441

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants