diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-08-05 21:31:36 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-08-07 02:46:04 +0900 |
| commit | 72a931a71a4722c0e56b231d07787bef608ceedc (patch) | |
| tree | 7de0a75a8d091ceb78f89a040af79f9c806710f3 /test/interactive/vm.nix | |
| parent | 9a25542c6d23fd4dc12f25fa914e6f560f4d7324 (diff) | |
nix: interactive nixos vm
This is useful for quickly spinning up an ephemeral hakurei environment for testing changes or reproducing vm test failures.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'test/interactive/vm.nix')
| -rw-r--r-- | test/interactive/vm.nix | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/interactive/vm.nix b/test/interactive/vm.nix new file mode 100644 index 00000000..c1239a64 --- /dev/null +++ b/test/interactive/vm.nix @@ -0,0 +1,55 @@ +{ + virtualisation.vmVariant.virtualisation = { + memorySize = 4096; + qemu.options = [ + "-vga none -device virtio-gpu-pci" + "-smp 8" + ]; + + mountHostNixStore = true; + writableStore = true; + writableStoreUseTmpfs = false; + + sharedDirectories = { + cwd = { + target = "/mnt/.ro-cwd"; + source = ''"$OLDPWD"''; + securityModel = "none"; + }; + }; + + fileSystems = { + "/mnt/.ro-cwd".options = [ + "ro" + "noatime" + ]; + "/mnt/cwd".overlay = { + lowerdir = [ "/mnt/.ro-cwd" ]; + upperdir = "/tmp/.cwd/upper"; + workdir = "/tmp/.cwd/work"; + }; + + "/mnt/src".overlay = { + lowerdir = [ ../.. ]; + upperdir = "/tmp/.src/upper"; + workdir = "/tmp/.src/work"; + }; + }; + }; + + systemd.services = { + logrotate-checkconf.enable = false; + hakurei-src-fix-ownership = { + wantedBy = [ "multi-user.target" ]; + wants = [ "mnt-src.mount" ]; + after = [ "mnt-src.mount" ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + script = '' + chown -R alice:users /mnt/src/ + ''; + }; + }; +} |
