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

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