-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add build-vm subcommand to nh os build
to build a VM start script.
#208
base: master
Are you sure you want to change the base?
Conversation
Yeah, as you probably saw, the types don't allow to have custom flags for each subcommand. You add make more spaguetti types like so, but I'm not sure I'm a fan: pub enum OsSubcommand {
Switch(OsRebuildArgs),
Build(OsBuildArgs),
// ...
}
struct OsBuildArgs {
#[command(flatten)]
common: OsRebuildArgs,
#[arg(long)
vm: bool
}
Indeed |
I have the hardware to test if needed, but there is also a github action that you can use to test. |
Thanks confirming, I'll switch the subcommand over to build-vm get a new patch pushed up tonight. |
I might add some nix ci testing to test all the functions. |
nh os build
to build a VM start script.
d2e52bb
to
f6dc0cb
Compare
This commit adds the `nh os build-vm` subcommand to build a virtual machine activation script instead of a full system. This includes a new option --with-bootloader/-B that applies to just build-vm, to build a VM with a bootloader.
I've changed it to be the build-vm subcommand. I've tested on my different system configurations and it works the same as On researching NixOS images on Darwin, I found Nix documentaiton that states that the process of building a NixOS VM is a bit different in Darwin. I'm not familiar at all with MacOS or Darwin, so I would have to leave that part to someone else. I've backed out my changes so it's NixOS Linux VMs being built on Linux only. There are four commits off master in my build-vm branch The first commit "Add build-vm subcommand to nh os." is the main one with build-vm implemented, and --with-bootloader option. The second commit disables nvd if the system hostname is different from the target hostname. Assuming that you only want to diff the versions if you are building for your local machine, rather than for another machine, or a VM. This might not be the desired behaviour, so anyone with push access can feel free to skip this change. |
This commit adds the boolean argument
--vm/-v
to build a virtual machine activation script instead of a full system. Note that this only applies to theos build
subcommand, since it doesn't entirely make sense to switch to a VM, as I don't believe it's currently possible to switch between guest versions on the host or the guest directly without restarting the guest.The patch #74 was created in May 2024, which proposed to create a build-vm subcommand, but was never fully implemented. This is fully working, though I've only tested it on flakes on NixOS. There's two outstanding todo's:
--vm
option for thenh os build
subcommand.Please let me know if you'd be willing to merge a completed patch, and I can sort out those todo's. My feeling is after writing this, that it would make more sense to have a full subcommand like pr 74 suggested. That way it's neater to add VM specific options (such as adding a with --with-bootloader) to act like
#config.system.build.vmWithBootloader
.build-image
is also possible, but looks to be a little more work since it's handled a bit differently for flakes vs plain Nix. See https://github.com/NixOS/nixpkgs/blob/481c7ead0aafb3d6dfa863ae87e3fdd6badc0b28/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh#L832Just let me know if you'd merge this patch if I finish it off, and whether you'd prefer a build-vm sub-command or
--vm
option on the build command. I'm happy to do either, butnh os build-vm
would be my vote.