Access NUR in imported module in home-manager

I have added NUR to my flake and pass it

configuration = import ./home/home.nix {
          inherit nur pkgs;
          inherit (pkgs) config lib stdenv;
        };

to my home-manager config.
In there the nur variable is in scope. However I have ./programs/firefox in my imports list.
Firefox/default.nix is a function

{ config, pkgs, nur, ... }:
  {program.firefox = {
    enable = true;
    extensions = with nur.repos.rycee.firefox-addons; [...];
};
}

and without the line extensions = … it works fine, but with I get the error

error: attribute 'nur' missing

       at /nix/store/4dng3sm5c3rxxw10vhx9lr9fclisz3zv-source/lib/modules.nix:365:28:

          364|         builtins.addErrorContext (context name)
          365|           (args.${name} or config._module.args.${name})
             |                            ^
          366|       ) (lib.functionArgs f);
(use '--show-trace' to show detailed location information)```

Instead of manually importing the module and providing the args you should abuse the module system:

configuration._module.args = { inherit nur; };
configuration.imports = [ ./home.nix ];
2 Likes