Running NixOS from any Linux Distro in systemd-nspawn Containers
Running NixOS from any Linux Distro in systemd-nspawn Containers
Running NixOS from any Linux Distro in systemd-nspawn Containers
When showing Nix or NixOS to newcomers, the first instinct is often to run the NixOS Docker image on Docker or Podman. This week we’re having a look at how to do the same with systemd’s systemd-nspawn facility via the machinectl command. This has huge benefits to both trying out NixOS and also professionally using it like a sidecar VM, as we shall see. If you’re using Ubuntu, Debian, Fedora, Rocky Linux, or similar, jump right in!
In this tutorial-like article, we learned, how to quickly run a nearly full instance of NixOS on any GNU/Linux distribution that uses systemd (e.g. Ubuntu, Debian, Fedora, Rocky Linux, etc…).
This NixOS instance can be configured to our needs and also be run like a sidecar to our normal host system. systemd can treat it like a system service that boots up by default with the host system, using machinectl enable nixos.
Finally someone taking advantage of what systemd has to offer instead of bitching around.
TIL, thanks!
You can declare containers when building a nixos system, and it also uses systemd-nspawn
That is pretty cool.
But its also another example of systemd doing stuff other services already did (see lxc).
And?
systemd manages cgroups, a very well standardized kernel interface for process management, which I would say is something init should be able to do. The gap between that, and a container is mostly semantic.
LXC is way more resource intensive and actually systemd had containers for a very long time... not to forget that if you use those you don't need to install one more thing :)