blueprint icon indicating copy to clipboard operation
blueprint copied to clipboard

Common configuration for every host

Open henrikolsson opened this issue 9 months ago • 3 comments

I'm not sure if this is already possbile, but if not:

I would like to have a way to add configuration that is used for each defined host. For example importing a common module or setting the hostname automatically to the name of the directory containing the configuration.

henrikolsson avatar Mar 25 '25 11:03 henrikolsson

It's possible by explicitly importing a common module in each hosts configuration. But I think you're asking for an implicit way to do so?

If we do so, we should probably do so not only for nixos, but for darwin, system-manager and maybe home-manager as well. One way would be to special-case a certain module name, i.e. all and then extend our loadHosts functions to always add e.g. modules.nixos.all, modules.darwin.all, etc if that exists.

Personally, I prefer importing everything explicitly as I think there's already too much implicit behavior in NixOS. But the implementation could probably remain minimal so no objection in principle from my side. Curious what others think :)

phaer avatar Mar 25 '25 13:03 phaer

I'm porting my current nix config to blueprint. In mine I wrap the loading of each host with some things that are common for each host, pretty much setting hostname and importing modules.

I'm no nix expert, but maybe it would be possible to add a hook in the configuration? That would be more explicit than "magic" files.

henrikolsson avatar Mar 25 '25 14:03 henrikolsson

I'm porting my current nix config to blueprint. In mine I wrap the loading of each host with some things that are common for each host, pretty much setting hostname and importing modules.

I'm no nix expert, but maybe it would be possible to add a hook in the configuration? That would be more explicit than "magic" files.

what do you mean with a hook?

JumpIn-Git avatar Mar 26 '25 14:03 JumpIn-Git