This is a work in progress proof of concept for a simple alternative to NixOS containers. It contains NixOS modules for a host machine and a container to run declarative NixOS nspawn containers.
Imperative containers are not in scope of this project since it is the author's opinion that those are the main issue holding back the upstream NixOS container migration to proper systemd-nspawn support. Imperative containers need a separate state outside of the NixOS module system and therefore a tool to manage that state. The author suggests importing the official container tarball and using the regular imperative NixOS deployment options instead.
machinectl
-M
flag for systemctl
and loginctl
works as intended[email protected]
unitsystemd-networkd
You can consume this flake and use the provided NixOS modules. See the simple-container
check
in checks.nix
for an example. If you are not using flakes, the NixOS modules are located in
host.nix
and container.nix
.