Hello,
I’m still learning nix(lang|pkg|os). I’m trying to move some of my ansible scripts to nixos flakes.
I have a git repo, with a few flakes inside:
./flake.nix # "root" flake
./servers/hetzner-cloud/flake.nix # generic server flake, used with nixos-anywhere
./clients/client-foobar/flake.nix # client specific server configuration and deployment, used with nixos-rebuild --target-host=...
Root flake includes (in inputs, type path
) both hetzner-cloud and client-foobar flakes.
Also client-foobar flake includes hetzner-cloud flake (so it’s self-contained, reuses modules from hetzner-cloud.nixosConfigurations).
What I am trying to achieve is separation between “server setup” (./servers) and “deployment” (./clients).
I will expose cli commands (defined in “sub” flakes) via root flake’s apps
or devShells.${system}.packages
.
I have couple of questions:
-
When I update client-foobar or hetzner-cloud flakes (or modules, that those flakes use) - I need to do
nix flake update
for root flake, otherwise root flake doesn’t “see” changes in “sub” flakes. This also updates all the other inputs of flakes (disko, systems, etc…).
How can I avoid this? I’ve already hit github’s rate limiter while tinkering
Documentation says that when flake is in git repo then thepath
type becomesgit+file
. Which, I assume, reads flake from git repo (not directly from directory). But even if the changes are unstaged - they are picked up after I donix flake update
. So I think something else is going on there, -
Is my approach viable?
Maybe it’s better to have one (root) flake and import a bunch of nix modules into it (./clients/client-foobar.nix, ./servers/hetzner.nix and etc.)?