How to use with home-manager?

Hi, I’ve only been using nix for a bit less than a week. I’ve mostly been able to figure things out but hitting this one slight stumbling block. I have fish working as my shell with home-manager

This is how I’m doing it which I think is pretty standard: = {
    enable = true;
    shellInit = ''
      if test -e /nix/var/nix/profiles/default/etc/profile.d/
        source /nix/var/nix/profiles/default/etc/profile.d/
    interactiveShellInit = ''
      set -U Z_CMD "j"
      set -gx DIRENV_LOG_FORMAT ""
    shellAliases = {
      vim = "nvim";
    plugins = [
        name = "z";
        src = pkgs.fetchFromGitHub {
          owner = "jethrokuan";
          repo = "z";
          rev = "85f863f20f24faf675827fb00f3a4e15c7838d76";
          hash = "sha256-+FUBM7CodtZrYKqU542fQD+ZDGrd2438trKM0tIESs0=";

However I see that nix/ at 62960f32915909a5104f2ca3a32b25fb3cfd34c7 · NixOS/nix · GitHub exists and if I manually download that and source that, it completions work great. I’m a bit surprised it’s not in the fish config that home-manager installs by default (same with the nix-daemon stuff too), but I don’t mind having to be more explicit about including it. I just cant figure out where it lives on my machine?

Or maybe it doesn’t get included anywhere, and you are just supposed to download it and put it somewhere? I’m just looking for some help getting pointed in the right direction. Thanks!

If you’re on NixOS just add environment.pathsToLink = [ "/share/fish" ];. This works because the completion script is included in the nix package under that path.

Thanks for the reply! I’m on macos though, not nixos.

I haven’t tried it but it looks like you can put the completion script in ~/.config/fish/completions or a few other places using home-manager’s xdg.configFile option:

xdg.configFile."fish/completions/".source = "${pkgs.nix}/share/fish/vendor_completions.d/";
1 Like

Thanks, that worked perfectly!

I saw your reply come in by email, but wasn’t able to try it right away, then forgot to try it until I got frustrated again at lack of tab complete, and remembered again.

1 Like