I have been creating and testing on my nixos flake but there are some changes i would like to first test before trying to build on my machine, im trying to follow the instructions o nixos.dev and others but im really stuck in how to create a virtual machine, place my flake on it and configure as if i would be doing on my machine
so far i created an user/vm/configuration.nix and am able to boot the vm but how can i place my flake inside the instalation and how should i rebuild the system? is it withing the vm or from the outside? what if i want to create another flake?
sorry im quite dumb and confused, plz help.
You can do either, but I’d personally build it from outside.
Write a config and use nixos-rebuild build-vm
to build it.
Then run ./result/bin/nixos-vm
to start it (the script would be named after your hostname, which is nixos
by default).
i want to test some changes to the flake file itself, from what i understood, correct me if im wrong, nixos-rebuild build-vm
isnt affected by the flake right?
I don’t understand your question.
If you want to rebuild your config to generate a vm, build-vm
is the subcommand to use, whether you use flakes or not.
sorry im confused myself, one of the changes i want to apply is moving home manager from a module to a standalone and have it defined on the flake output. this is why i want to test it on a vm so that i dont commit any mistake and end up locked out of my user.
so if i create a new flake like that will the vm be affected?
You’d have to rebuild within the vm, in that case. Ensure your vm has nix enabled and home-manager available.
what should i add to my vn’s configuration.nix
to allow for that?
also, the rebuild you mentioned is a nixos rebuild or a homemanager rebuild?
You have to rebuild your hm config within the vm since hm cannot manage system config,.
So its the home manager, alright thanks.
also where are the system files? it would be helpful to be able to copy files from my system to the vm