How to build a standalone NixOS QEMU VM?

You haven’t told where lib should come from…

Perhaps the following might work:

nix-build '<nixpkgs/nixos>' - <<'EOF'
let pkgs = import <nixpkgs> {}; in
(import <nixpkgs/nixos/lib/make-disk-image.nix> {
    inherit (pkgs) lib config;
    pkgs = import <nixpkgs> { inherit (pkgs) system; };
    diskSize = 10240;
    format = "qcow2";
}).system.build.qcow2
EOF
1 Like