Confused why my home-manager overlay setup isn't working

Hi all,

I am attempting to create an overlay for a package to apply in home-manager like so:

nixpkgs.overlays = [
  (import ./overlays/weechat.nix)
];

with the following in overlays/weechat.nix:

final: prev:

{
  weechat = prev.weechat.override {
    configure = { availablePlugins, ... }: {

      plugins = with availablePlugins; [
        python
      ];

      scripts = with final.weechatScripts; [
        wee-slack
        weechat-matrix
      ];
    };
  };
}

and referencing it like:

home.packages = with pkgs; [ weechat ];

but this is not picking up the modifications. To test this, I tried changing the overlay attribute name to something else, such as weechatCustom, and referencing that in the home.packages list, in which case nix complains that weechatCustom attribute is missing.

Some additional data points that might or might not be relevant:

  1. I am using flakes.
  2. I am using this on an OSX machine in conjunction with nix-darwin.
  3. I have set useGlobalPkgs and useUserPackages to true.

I have been staring at this for some time. Does anyone notice anything obviously wrong with this setup?

1 Like

I don’t know enough about weechat to know if you are doing that part correctly or not, but one thing to try is to make sure you don’t have weechat also installed independently in your user profile via nix-env. So try

nix-env -e weechat

Looking at what you wrote more my previous suggestion might not be that good. How about you try:

{
  home.packages = with pkgs; [ 
    (weechat.override {
      configure = { availablePlugins, ... }: {

        plugins = with availablePlugins; [
          python
        ];

        scripts = with weechatScripts; [
          wee-slack
          weechat-matrix
        ];
      };
    }) 
  ];
}

Yes, that works! Do you happen to know why this works, while the earlier one does not?

1 Like

No, but my guess is that the overlays you define in

nixpkgs.overlays

are only applied to the nixpkgs that is made available to your user on the NIX_PATH, rather than the nixpkgs used by home-manager configuration.

Thanks for your quick help!

1 Like

@tni you might try

let
  pkgs = import nixpkgs {
    overlays = [
      (final: prev:

{
  weechat = prev.weechat.override {
    configure = { availablePlugins, ... }: {

      plugins = with availablePlugins; [
        python
      ];

      scripts = with final.weechatScripts; [
        wee-slack
        weechat-matrix
      ];
    };
  };
})
    ];
    config = { };
  };
in {
# ...
home.packages ...
 }

Thank you so much for looking at this. The snippet as-is doesn’t quite work for me, I think because I am using flakes, and importing nixpkgs is done differently? I tried a few other variations of what you posted, including some that forced me to run using --impure and didn’t manage to crack it. Weird :slight_smile:

I’ve not yet approached flakes myself …

1 Like

I feel you. I started using nix recently and started with flakes, and I don’t want to learn the non-flake approach myself. Not enough brain space lol

2 Likes