How to use external home-manager module in home-manager itself used as NixOS module?

Hi there,

I am currently using home-manager as NixOS module as described here.

I want to add nix-doom-emacs-unstraightened, and use that in my user config defined by home-manager, but I don’t understand how to do that. I tried using the overlay method as well, but nixpkgs.overlays = [ nix-doom-emacs-unstraightened.overlays.default ]; reports as it could not find nix-doom-emacs-unstraightened, which tells me I have failed to propagate it as input from flake inputs to where it is being used to add overlay.

For reference, my NixOS config structure is pretty much unchanged from here → payas/nixos: Archived. All maintenance and development now happens as part of monorepo. - bhankas/forgejo.

Thanks in advance!

If you added nix-doom-emacs-unstraightened to inputs as described in the link, then this should work:

nixpkgs.overlays = [ nix-doom-emacs-unstraightened.overlays.default ];

If you add nix-doom-emacs-unstraightened to your args in outputs in your flake.nix:

  outputs =
    { self
    , nixpkgs
    , home-manager
    , agenix
    , nixos-hardware
    , deploy-rs
+   , nix-doom-emacs-unstraightened # <--- this part added here
    , ...

Otherwise you can just add inputs and not add it to outputs args:

nixpkgs.overlays = [ inputs.nix-doom-emacs-unstraightened.overlays.default ];

If you are doing it in different modules and not flake.nix you need to propagate it with specialArgs.

About using HM module - you can either add it into imports for each user:

-                    payas = import ./hosts/hermes/home.nix;
+                    payas = {
+                      imports = [
+                        inputs.nix-doom-emacs-unstraightened.hmModule
+                        ./hosts/hermes/home.nix;
+                      ];
+                    };

or add it to home-manager.sharedModules if you want to add it to all users in that NixOS system:

                home-manager = {
                  useGlobalPkgs = true;
                  useUserPackages = true;
+                 sharedModules = [ inputs.nix-doom-emacs-unstraightened.hmModule ];
                  users = {
1 Like

Ahh, this is what I was really missing! I should have read wiki entry more thoroughly :slight_smile:

It works now, and I learned more flakes in the process, thanks a lot!