In the amazing nixos, it is possible to launch a lightweight container that will run a system whose configuration.nix file is different from the host configuration by using:

nixos-rebuild build-vm -I nixos-config=./configuration.nix

However, this command cannot work on operating systems where nixos is not installed, like debian + nixpkgs, because nixos-rebuild does not exists.

How can I still use build-vm in non-nixos systems?


Thanks to clever and infinisil:

nix-build '<nixpkgs/nixos>' -A vm -I nixos-config=./configuration.nix
| improve this answer | |
  • You can mark your answer as accepted since this is, well, the right answer – David Costa Oct 5 '19 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.