Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support nested hosts directory #53

Open
arianvp opened this issue Jan 10, 2025 · 4 comments
Open

Support nested hosts directory #53

arianvp opened this issue Jan 10, 2025 · 4 comments
Labels
enhancement New feature or request

Comments

@arianvp
Copy link

arianvp commented Jan 10, 2025

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

@arianvp arianvp added the enhancement New feature or request label Jan 10, 2025
@phaer
Copy link
Member

phaer commented Jan 10, 2025

Not quite a duplicate, but probably some overlap with #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?

@arianvp
Copy link
Author

arianvp commented Jan 10, 2025

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

@arianvp
Copy link
Author

arianvp commented Jan 10, 2025

I thought / was a common pattern. e.g. also used in flake-utils.flattenTree

@zimbatm
Copy link
Member

zimbatm commented Jan 10, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants