nix-darwin
nix-darwin copied to clipboard
Completions for nix will conflict with Nix 2.4
Nix 2.4 defines its own zsh completions. When I used https://github.com/NixOS/nixpkgs/pull/144197's pkgs.nix
as my nix.package
, I started getting errors during the build:
error: collision between `/nix/store/j5i4bhqa2dh8wk98l0g2csnmz63l2k9y-nix-2.4/share/zsh/site-functions/_nix' and `/nix/store/bbz7556b8yk668y1dpyma3qcwhrswf0d-nix-zsh-completions-0.4.4/share/zsh/site-functions/_nix'
I believe the problem is that enabling the programs.zsh.enableCompletion
option does two things:
https://github.com/LnL7/nix-darwin/blob/44da835ac40dab5fd231298b59d83487382d2fab/modules/programs/zsh/default.nix#L103
- adding
pkgs.nix-zsh-completions
to system packages - run
autoload -U compinit && compinit
in /etc/zshrc
I would suggest either splitting the option into two (both defaulting to true, to be consistent with the current behavior) or removing the first behavior.
As a workaround, I'm looking into whether I can rely on home-manager's zsh setup to call compinit instead (and disable this flag completely), worst case overriding nix-zsh-completions
to an almost-empty package.
Update: I had something else that was wrong in nix-darwin setup, apparently just disabling the option here makes things okay (home-manager's zsh will call compinit anyway)
I got the exact same error and thought it was just me
I've been scratching my head on this issue for hours without a solution. I'm using nix-darwin and home-manager via a nix flake and I'm installing zsh using home-manager's programs.zsh.enableCompletion
@kubukoz can you explain what was the issue with your nix-darwin config which solved this?
I don't use home manager, but I've been able to work around this problem for now with programs.zsh.enableCompletion = false;
and then adding autoload -U compinit && compinit
to programs.zsh.interactiveShellInit
.
I ported over the fix from nixpkgs for this issue: https://github.com/LnL7/nix-darwin/pull/379
Now that NixOS/nixpkgs#146030 is in nixpkgs (and I believe backported to 21.11), I think/hope this can be closed?
I still have this while I was trying to unstable Nix 2.5 (via the unstable channel).
The workaround described previously seems to work for me.
Here is the config I use:
programs.zsh = {
enable = true;
enableCompletion = false;
interactiveShellInit = "autoload -U compinit && compinit";
};
Looks like this should be fixed in 22.05 and above; please comment here if you're still experiencing it.