Zsh-vi-mode in systemPackages, but result not merged into system

Greetings! Nix noob here.

I’ve been using nix-darwin to manage many packages on macOS for a few days with good results, but I have run into a problem that I cannot seem to diagnose.

I added zsh-vi-mode to my environment.systemPackages, expecting that after a darwin-rebuild switch, I would find its output in /run/current-system/sw/share/zsh-vi-mode. But, it simply does not.

I’ve tested building the package in several different ways, with e.g. nix-shell and nix build; and in these cases the result looks correct.

% nix build --impure --expr '(import <nixpkgs> {}).zsh-vi-mode'
% tree result
result
└── share
    └── zsh-vi-mode
        ├── zsh-vi-mode.plugin.zsh
        └── zsh-vi-mode.zsh
% cat ~/.config/nix-darwin/flake.nix
…
  environment.systemPackages = with pkgs; [
…
      zsh-vi-mode
  ];
…
% darwin-rebuild --flake ~/.config/nix-darwin switch --verbose --show-trace
building the system configuration...
…
setting nvram variables...
% ls /run/current-system/sw/share/zsh-vi-mode
ls: cannot access '/run/current-system/sw/share/zsh-vi-mode': No such file or directory

I’m grateful for any troubleshooting suggestions!

Solved. By default, only these package output paths are included in the system:

environment.pathsToLink = [
  "/bin"
  "/share/locale"
  "/share/terminfo"
];

github link

After adding environment.pathsToLink = [ "/share/zsh-vi-mode"];, the package’s files are symlinked from /run/current-system/sw/share/zsh-vi-mode as expected.

Interestingly, the package results are only kept in the store if I use pathsToLink as above, or reference the package output some other way in the configuration. For example, by setting an entry in environment.variable to ${pkgs.zsh-vi-mode}, or even with just echo ${pkgs.zsh-vi-mode} in system.activationScripts.postActivation.