feat: test config in a vm

This commit is contained in:
Daniel Langbein 2025-01-03 15:43:55 +01:00
parent 3de51a4f89
commit 27b26d8dcc
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002
2 changed files with 26 additions and 0 deletions

View File

@ -19,6 +19,7 @@ See also:
* [Default configuration](#default-configuration)
* [Apply modified configuration](#apply-modified-configuration)
* [ARM: Vanilla UEFI bootloader for the Raspberry Pi 3B+](#arm-vanilla-uefi-bootloader-for-the-raspberry-pi-3b)
* [Test config changes in a VM](#test-config-changes-in-a-vm)
* [Update, build and switch](#update-build-and-switch)
* [tldr](#tldr)
* [Update](#update)
@ -158,6 +159,20 @@ Then install NixOS the way you prefer, but don't touch/modify the partition tabl
See https://nixos.wiki/wiki/NixOS_on_ARM/UEFI#Installing
## Test config changes in a VM
https://nix.dev/tutorials/nixos/nixos-configuration-on-vm.html
- See `base.nix` -> `virtualisation.vmVariant` for build-vm specific options
- Import of `./hardware-configuration.nix`
- As build-vm uses `mkVMOverride` we can just leave the import
- If in doubt, remove/uncomment it
```shell
nix-build '<nixpkgs/nixos>' -A vm -I nixos-config=./hosts/yodaTux/configuration.nix
./result/bin/run-yodaTux-vm && rm yodaTux.qcow2
```
## Update, build and switch
### tldr

View File

@ -88,4 +88,15 @@
# https://nixos.wiki/wiki/Firewall
# Note: Firewall rules may be bypassed/overwritten by Docker, as per https://github.com/NixOS/nixpkgs/issues/111852
networking.firewall.enable = true;
# Options only for build.system.vm - they wont get applied when building build.system.toplevel aka the normal system config.
# https://discourse.nixos.org/t/wayland-compositors-an-build-vm-not-working/46486/2
virtualisation.vmVariant = {
users.users.yoda.initialPassword = "asdf";
virtualisation.qemu.options = [
"-device virtio-vga-gl"
"-display sdl,gl=on,show-cursor=off"
"-m 8G"
];
};
}