I was able to create a simple nix flake wrapping a nix module I defined which just adds pkgs.hello to system env packages, and added it as a module in my main system flake for NixOS and got it rebuilt and working.
Or should I not be using a flake for this? Can I import or add to modules a remote nix module, from github? Would it help if I made a derivation for the nix module instead then added to flake outputs packages?
Not related to your question, but judging from the formatting you seem to be under the impression that home-manager.nixosModules.home-manager is a function that is being called with an attribute set after it:
{
modules = [
# It looks like you are calling a funciton, you're not
home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
}
];
}
When in reality they are item 1 and 2 of the modules list:
{
modules = [
(home-manager.nixosModules.home-manager)
# No relation between the two
({
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
})
];
}
Thanks for pointing out the mis-use of home-manager nix flake module. Got confused reading import usage and imports and modules spec. That’s interesting nix module spec can be a function or an attr set.
I don’t think flake outputs homeManagerModules is a standard or part of any spec that I can see. Trying it, I get an error in my system flake that homeManagerModules is missing from inputs.test1.homeManagerModules.default.
I could also be packaging the module flake importing as nix module using home-manager.sharedModules instead of defining a home manager module. Maybe that makes it easier.
Testing the home-manager config inline works, but the goal is to package as a nix flake module.
My solution is to package my desktop app as a nix module instead of nix flake. Then in my system flake.nix I can fetch the remote nix module in declaration then import it.