nixos-build-vms(8)
π nixos-build-vms(8) β the manual page, but make it make sense β¨
okay bestie, welcome to section 8 of the System Manager's Manual, and buckle up because this one's actually kind of cool π
π NAME π
nixos-build-vms β build a whole network of virtual machines from a network of NixOS configurations π₯οΈβ¨π₯οΈ
β¨ SYNOPSIS β¨
nixos-build-vms [--show-trace] [--no-out-link] [--help]
[--option name value] network.nix
that's it. that's the whole vibe check. one file in, a fake little internet out π¦
π DESCRIPTION π
so basically, this command builds a network of QEMU-KVM virtual machines from a single Nix expression that describes a network of NixOS machines. yes, a whole network. from one file. main character energy fr fr π
once it's built, you can start the whole virtual network by running the bin/run-vms shell script that this command generates. it literally hands you the keys π«Ά
and by default it produces a result symlink that points at the generated virtual network, so you can find your little baby again later. cute.
a network Nix expression looks like this, bestie β memorize the shape, not the content:
{
test1 = {pkgs, config, ...}:
{
services.openssh.enable = true;
nixpkgs.localSystem.system = "i686-linux";
deployment.targetHost = "test1.example.net";
# Other NixOS options
};
test2 = {pkgs, config, ...}:
{
services.openssh.enable = true;
services.httpd.enable = true;
environment.systemPackages = [ pkgs.lynx ];
nixpkgs.localSystem.system = "x86_64-linux";
deployment.targetHost = "test2.example.net";
# Other NixOS options
};
}
okay so breaking that down πΈ β every attribute in the expression is one machine in the network (think test1 and test2 up there), and each one refers to a function that defines a NixOS configuration.
inside each NixOS configuration, two attributes are special and you should lowkey pay attention:
deployment.targetHostβ tells you the address (domain name or IP address) of the system, and ssh uses it to perform remote deployment operations. it's giving "where do I knock" πͺnixpkgs.localSystem.systemβ lets you pick an architecture for the target machine, like'i686-linux', which builds a 32-bit NixOS configuration. very demure, very cross-compiled π§
and if you just... don't include that nixpkgs.localSystem.system property at all? no stress β it'll build the configuration for the same architecture as the host system. default behavior, slay π
π₯ OPTIONS π₯
--show-traceβ shows a trace of the output. when things go sideways, this is your receipts π--no-out-linkβ do not create aresultsymlink. no little shortcut left behind, we love a clean exit.-h,--helpβ shows the usage of this command to the user. the classic "help me help you" π«Ά--optionname value β set the Nix configuration option name to value. this overrides settings in the Nix configuration file (seenix.conf(5)). yes, overrides. it wins. periodt π
π AUTHORS π
Eelco Dolstra and the Nixpkgs/NixOS contributors β absolute icons, no cap π
nerdiest footnote ever but: this page lives on Debian, dated January 1, 1980 (yes really, the epoch birthday π), and it's page nixos-build-vms(8) of the System Manager's Manual. mwah, go build a tiny internet ππ
π¦ where this page comes from
- nixos 26.05: nixos-build-vms
- nixpkgs unstable: nixos-build-vms
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms