How to use packaged fish plugins in home-manager

Hello everyone,

I am trying to understand how to add a fish plugin to my fish shell in my home-manager configuration and activate it. In the nixos-wiki-fish I could find how to use fish plugins from github like this:

 programs.fish.enable = true;
 programs.fish.plugins = [
   {
     name = "z";
     src = pkgs.fetchFromGitHub {
       owner = "jethrokuan";
       repo = "z";
       rev = "e0e1b9dfdba362f8ab1ae8c1afc7ccf62b89f7eb";
       sha256 = "0dbnir6jbwjpjalz14snzd3cgdysgcs3raznsijd6savad3qhijc";
     };
   }
   { name = "grc"; src = pkgs.fishPlugins.grc.src; }
  ];

however, I don’t know how to add an already packaged fishPlugin to my home-manager configuration. When I try the following configuration:

programs.fish = {
  enable = true;
  plugins = with pkgs.fishPlugins; [ tide ];
};

I get the error:

error: undefined variable 'tide'

       at /home/user/.config/nixpkgs/home.nix:113:40:

          112|     };
          113|     plugins = with pkgs.fishPlugins; [ tide ];
             |                                        ^
          114|   };

       … while evaluating the attribute 'value'

and when I try:


programs.fish = {
  enable = true;
  plugins = [ { name = "tide"; src = pkgs.fishPlugins.tide.src; } ];
};

I get the error:

error: attribute 'tide' missing

       at /home/user/.config/nixpkgs/home.nix:114:30:

          113|     plugins = [
          114|       { name = "tide"; src = pkgs.fishPlugins.tide.src; }
             |                              ^
          115|       # { name = "colored-man-pages"; src = pkgs.fishPlugins.colored-man-pages.src; }

       … while evaluating the attribute 'fishPlugins.tide.src'

I am new to nix and I don’t know how I can do this correctly. Can anyone help me to troubleshoot this or tell me how I am doing this wrong? I also read something about wrapFish in nixpkgs-fish, but I don’t really know how to use it. Any help is greatly appreciated!

1 Like

What channel are you using to build your configuration?

That plugins seems only to exist in unstable and 22.11.

1 Like

Thanks for the quick reply. I was on home-manager 22.05. I changed it to unstable:

~/.config/nixpkgs~> nix-channel --list

home-manager https://github.com/nix-community/home-manager/archive/master.tar.gz

When I now do home-manager switch with this config:

{ config, pkgs, ... }:

{
  home.username = "user";
  home.homeDirectory = "/home/user";

  home.packages = with pkgs; [
    exa
  ];

  programs.fish.enable = true;
 
  nixpkgs.config.allowUnfree = true;

  home.stateVersion = "22.05";
  programs.home-manager.enable = true;
}

, I get another error :

~/.config/nixpkgs~> home-manager switch                                               2650ms  Fr 13 Jan 2023 11:35:10 CET
error: attribute 'numbers' missing

       at /home/tipi/.nix-defexpr/channels/home-manager/modules/services/picom.nix:144:14:

          143|     activeOpacity = mkOption {
          144|       type = types.numbers.between 0 1;
             |              ^
          145|       default = 1.0;
(use '--show-trace' to show detailed location information)                                    

any idea why? I don’t even have picom in my config …

(Btw: I am using nix on Fedora 37, if it is relevant at all)

You have not updated your nixpkgs to unstable, but only the home-manager channel.

From what we can see in your channel list, you are inheritting nixpkgs from the systems nixos channel.

1 Like

Yes you were right. The Issue was with the channels. Thank you very much for your help!