From dee73139edd5b55e76281a37aaf122328f51d4a4 Mon Sep 17 00:00:00 2001 From: Mika Tammi Date: Thu, 28 Sep 2023 17:39:22 +0300 Subject: [PATCH] Shared /nix/store and read-write tmpfs overlay /nix/store is shared read-only from the host, and in debug mode, there is read-write tmpfs overlay on top of it, which allows usage of `nix-shell -p ...` inside the virtual machine. Signed-off-by: Mika Tammi --- modules/virtualization/microvm/appvm.nix | 11 ++++++++++- modules/virtualization/microvm/guivm.nix | 11 ++++++++++- modules/virtualization/microvm/netvm.nix | 11 ++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/modules/virtualization/microvm/appvm.nix b/modules/virtualization/microvm/appvm.nix index 32e37112d..06bec0700 100644 --- a/modules/virtualization/microvm/appvm.nix +++ b/modules/virtualization/microvm/appvm.nix @@ -56,7 +56,16 @@ mem = vm.ramMb; vcpu = vm.cores; hypervisor = "qemu"; - storeDiskType = "squashfs"; + + shares = [ + { + tag = "ro-store"; + source = "/nix/store"; + mountPoint = "/nix/.ro-store"; + } + ]; + writableStoreOverlay = lib.mkIf config.ghaf.development.debug.tools.enable "/nix/.rw-store"; + interfaces = [ { type = "tap"; diff --git a/modules/virtualization/microvm/guivm.nix b/modules/virtualization/microvm/guivm.nix index 7987157bf..b3fb88dc7 100644 --- a/modules/virtualization/microvm/guivm.nix +++ b/modules/virtualization/microvm/guivm.nix @@ -54,7 +54,16 @@ microvm = { mem = 2048; hypervisor = "qemu"; - storeDiskType = "squashfs"; + + shares = [ + { + tag = "ro-store"; + source = "/nix/store"; + mountPoint = "/nix/.ro-store"; + } + ]; + writableStoreOverlay = lib.mkIf config.ghaf.development.debug.tools.enable "/nix/.rw-store"; + interfaces = [ { type = "tap"; diff --git a/modules/virtualization/microvm/netvm.nix b/modules/virtualization/microvm/netvm.nix index 5b0ddd5cc..e21df6fee 100644 --- a/modules/virtualization/microvm/netvm.nix +++ b/modules/virtualization/microvm/netvm.nix @@ -73,7 +73,16 @@ }; }; - microvm.storeDiskType = "squashfs"; + microvm = { + shares = [ + { + tag = "ro-store"; + source = "/nix/store"; + mountPoint = "/nix/.ro-store"; + } + ]; + writableStoreOverlay = lib.mkIf config.ghaf.development.debug.tools.enable "/nix/.rw-store"; + }; imports = import ../../module-list.nix; })