ZSH completions not being loaded

Hello everyone, I’m a new nix user, and I’m having an issue with ZSH completions.

I’m using nix with nix-darwin on m1 mac. My config (irrelevant bits skipped): darwin-configuration.nix · GitHub

I installed the gopass package (https://github.com/NixOS/nixpkgs/blob/c32c39d6f3b1fe6514598fa40ad2cf9ce22c3fb7/pkgs/tools/security/gopass/default.nix), and it works well except for the fact that the ZSH completions are not being loaded.

I searched for completions in the system and found those files:

/nix/store/8njw5i6sbb805nfw03i68kfys0gvzwfp-gopass-1.13.0/share/zsh/site-functions/_gopass
/nix/store/6slykk9zyh30njfsnbkdf9vpxxvnyqfa-user-environment/share/zsh/site-functions/_gopass
/nix/store/x5jd6lvp2aals0g2nrra4bsgl2bsyk02-home-manager-path/share/zsh/site-functions/_gopass
/nix/store/waqaj9n5samada9ylgz7q29kj2b5vpas-gopass-1.13.0/share/zsh/site-functions/_gopass
/nix/store/yqa6a2dywwggiaqb35wyaagdkvqm49fi-system-path/share/zsh/site-functions/_gopass

But none of those paths is present in my $fpath. Also, my $fpath includes /Users/wojtek/.nix-profile/share/zsh/site-functions - I would expect the completion files to be symlinked there, but this directory does not exist at all.

When I run repl (nix repl '<nixpkgs>' '<darwin>' '<home-manager>') and then enter config.environment.pathsToLink it returns [ "/etc/profile.d" "/share/zsh" "/info" "/share/info" "/share/man" "/etc/bash_completion.d" "/share/bash-completion/completions" "/bin" "/share/locale" ].

As a workaround, I tried adding:

initExtraFirst = ''
  fpath=(${config.home-manager.users.wojtek.home.path}/share/zsh/site-functions/ $fpath)
'';

To my zsh config, which did indeed fix completions for gopass, but it also broke completions for nix (I think that’s because site-functions in home-manager include them as well, and so they’re being loaded twice).

Does anyone perhaps know how to fix this? Thanks for all the help!

3 Likes

The completions work OK on NixOS.

Seems relevant: bug: hm installed zsh completions aren't added to fpath · Issue #2562 · nix-community/home-manager · GitHub

1 Like