Support nested `hosts` directory
Is your feature request related to a problem? Please describe.
we have nesting in our hosts directory a la:
hosts/
production/
host1/
host2/
staging/
host3/
host4/
Describe the solution you'd like
would be neat if this would work and up with making
{
nixosConfigurations = {
"production/host1" = ...
"staging/host3" = ...
};
}
Describe alternatives you've considered
Flatten directory structure but make me sad
Additional context
Not quite a duplicate, but probably some overlap with https://github.com/numtide/blueprint/issues/51.
-
"/" as a separator in the attrset makes quoting necessary which can be a bit of an annoyance in the repl IMO. Are there drawbacks in replacing them with "-" in the attrset?
-
we should probably stop to recurse once we find a (darwin)-configuration.nix?
makes quoting necessary
Does it? This works fine for me (on zsh):
arian@Arians-MacBook-Pro try-blueprint % nix flake show
warning: Git tree '/Users/arian/Projects/try-blueprint' is dirty
git+file:///Users/arian/Projects/try-blueprint
└───nixosConfigurations
└───"production/host1": NixOS configuration
arian@Arians-MacBook-Pro try-blueprint % nix build .#nixosConfigurations.production/host1.config.system.build.toplevel
warning: Git tree '/Users/arian/Projects/try-blueprint' is dirty
[1/0/1 copied (175.8/175.8 MiB), 27.5 MiB DL] fetching source from htt
I thought / was a common pattern. e.g. also used in flake-utils.flattenTree
Alternatively, what if you could re-instantiate a blueprint?
- shared/flake.nix - a normal blueprint, with your hosts/ folder and everything.
- staging/flake.nix
{ inputs.shared.url = "path:../shared"; outputs = inputs: inputs.shared { inherit inputs; vars = { environment = "staging"; }; }; }
Where vars in a new global that gets injected everywhere in the blueprint and can be used to parameterize it.
And where the new instance of the blueprint would also merge in its own folder structure. So you can still override or add a host on staging or prod for special cases.
a possibly similar usecase: in my current config, my nixosConfigurations exist once with withSecrets=true and once with withSecrets=false. It lets me boostrap my config without having all my secrets available yet (which are copied manually).
For instance, I have a nixosConfiguration laptop and laptop-bootstrap = laptop.override { specialArgs = { withSecrets = false }.