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

programs.zsh: move evlauation of ${zshAliases} after cfg.interactiveShellInit #28378

Merged
merged 1 commit into from Aug 30, 2017

Conversation

Ma27
Copy link
Member

@Ma27 Ma27 commented Aug 18, 2017

Motivation for this change

⚠️ Caution: (possible) BC Break: This changes the order of operations in /etc/zshrc which might break several people's setups.

cfg.interactiveShellInit is used by modules like
programs.zsh.oh-my-zsh. This means that all aliases defined in
programs.zsh.shellAliases might be overriden which is highly
unpredictable in some cases.

Example:

oh-my-zsh overrides ll and l aliases in the core (no plugin which might be disabled), but I decided to use exa as ls replacement.
Now I tried to alias ls and ll to exa in programs.zsh.shellAliases, but it was overriden by oh-my-zsh as interactiveShellInit is evaluated after shellAliases.

A quickfix was to use mkAfter:

{
 programs.zsh.interactiveShellInit = pkgs.lib.mkAfter ''
   alias ls="${pkgs.exa}/bin/exa";
 '';
}

As you can see I create alias statements manually in a custom interactiveShellInit block, however I don't think that such hacks should be necessary to prevent such unexpectable behavior.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

…veShellInit`

`cfg.interactiveShellInit` is used by modules like
`programs.zsh.oh-my-zsh`. This means that all aliases defined in
`programs.zsh.shellAliases` might be overriden which is highly
unpredictable
@fpletz fpletz added this to the 17.09 milestone Aug 22, 2017
@fpletz fpletz merged commit 05c9a95 into NixOS:master Aug 30, 2017
@Ma27 Ma27 deleted the fix-zshrc-eval-order branch August 30, 2017 18:19
@Ma27
Copy link
Member Author

Ma27 commented Aug 30, 2017

thanks :)

uvNikita added a commit to nix-community/home-manager that referenced this pull request Sep 12, 2017
Same motivation as in NixOS/nixpkgs#28378.
zsh.initExtra parameter can be used by external modules which can
redefine user aliases. This change will give user-defined aliases
the highest priority.
pasqui23 pushed a commit to pasqui23/home-manager that referenced this pull request Oct 14, 2017
Same motivation as in NixOS/nixpkgs#28378.
zsh.initExtra parameter can be used by external modules which can
redefine user aliases. This change will give user-defined aliases
the highest priority.
@Ma27 Ma27 mentioned this pull request Jun 8, 2019
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants