NixOS / nixops

NixOps is a tool for deploying to NixOS machines in a network or cloud.
https://nixos.org/nixops
GNU Lesser General Public License v3.0
1.83k stars 363 forks source link

How does nixops work? #1554

Open thkoch2001 opened 1 year ago

thkoch2001 commented 1 year ago

I'm new to nixops and want to understand how it works before investing more time in it. Is there already such Documentation? If so, please make it easier to find! Thanks!

roberth commented 1 year ago

I'm new to nixops and want to understand how it works before investing more time in it. Is there already such Documentation? If so, please make it easier to find! Thanks!

The documentation has been stripped down since the separation into plugins.

But nonetheless, documentation exists

  • What are the steps that happen in the background when Nixops sets up a machine?

Depends on the chosen backend. If "none", it just expects to be able to ssh into it. Cloud backends will create a VM.

  • How does Nixops compare the current vs. the defined state and how does it correct any difference?

Depends on the backend, but I think there's more to say. This answer should be elaborated on if it isn't already in the docs.

As for the NixOS part of the deployment, it leaves that to NixOS and its activation script.

  • Is there a way that Nixops would continuously make the above comparison and correction?

nixops deploy is idempotent, so you could run it in a loop. This might be useful to recover from some very rare failures. Without a deployment model that takes more of the "environment" into account, such as system load, operating like this isn't super useful.

  • Is it correct, that Nixops main mode of operation is to build an image (locally) and than deploys it to target machines?

If I read this literally, not correct. It generally boots a very basic image, which is then customized by pushing a NixOS system closure to it. You could work with your own image, but the image is only relevant for first boot.

Maybe by "image" you referred to the system closure? It's the Nix equivalent of an image, but it's rarely if ever serialized into a byte stream like typical images are.

justinlovinger commented 1 year ago

Most of your questions are better answered by looking into NixOS than NixOps. Long-story-short, NixOps is a tool to push NixOS deployments, while NixOS is a reproducible, declarative, reliable Linux distribution. All the handling of state, dependencies, building, system configuration, etc. are done by NixOS.