How can I update a nixos-anywhere system?

I’m a bit confused. Is it possible to push an update for a nixos-anywhere system?

I tried to add a package to the flake, then push it, and it proceeds to format the whole drive again, wiping it clean;)

I know I can log into the system and switch to a flake, but the whole idea was that I was pushing the config to the system.

You don’t use nixos-anywhere after initial deployment.

nixos-rebuild supports remote deployment: https://github.com/NixOS/nixpkgs/blob/a77ab169a83a4175169d78684ddd2e54486ac651/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh#L124

There’s also a variety of third party remote deployment tools, I use deploy-rs personally.

All these tools fall back on nix-copy-closure under the hood, and then simply execute the activation script of the new generation via ssh. They differ mainly in how they execute the script and assert the remote is working afterwards.

1 Like