From f3c57067635b8d24eac9c9e8b7b07f4b543bc152 Mon Sep 17 00:00:00 2001 From: Snorre Date: Tue, 4 Mar 2025 13:45:46 +0100 Subject: [PATCH] fixed microvm --- flake.nix | 3 +-- lib/default.nix | 22 +++++++++++++++++----- modules/networking-metal.nix | 3 +-- modules/zfs.nix | 10 +++++++++- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index 64baebe..3f65c0d 100755 --- a/flake.nix +++ b/flake.nix @@ -50,8 +50,7 @@ inputs.agenix.nixosModules.default inputs.home-manager.nixosModules.default inputs.simple-nixos-mailserver.nixosModule - inputs.microvm.nixosModules.microvm - {microvm.hypervisor = "qemu";} + inputs.microvm.nixosModules.host ]; in { server-vm = nixpkgs.lib.nixosSystem { diff --git a/lib/default.nix b/lib/default.nix index 98141c1..77e66cc 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -14,15 +14,27 @@ nixpkgs.lib.extend ( config, }: {microvm, ...}: { imports = [microvm.host]; + microvm.hypervisor = "cloud-hypervisor"; microvm.vms.${name} = { pkgs = import nixpkgs {inherit system;}; + microvm.shares = [ + { + tag = "ro-store"; + source = "/nix/store"; + mountPoint = "/nix/.ro-store"; + } + ]; inherit config; - # Host build-time reference to where the MicroVM NixOS is defined - # under nixosConfigurations - flake = self; - # Specify from where to let `microvm -u` update later on - updateFlake = "git+file:///etc/nixos"; }; + # Mount host /nix/store for drastically reduced image size and evaluation time + microvm.vms.${name}.config.shares = [ + { + source = "/nix/store"; + mountPoint = "/nix/.ro-store"; + tag = "ro-store"; + proto = "virtiofs"; + } + ]; }; }; } diff --git a/modules/networking-metal.nix b/modules/networking-metal.nix index 0faba8b..b472032 100644 --- a/modules/networking-metal.nix +++ b/modules/networking-metal.nix @@ -1,5 +1,4 @@ -{...}: -{ +{...}: { networking.useDHCP = false; networking.wakeOnLan.enable = true; diff --git a/modules/zfs.nix b/modules/zfs.nix index 9cf6fa4..0277261 100755 --- a/modules/zfs.nix +++ b/modules/zfs.nix @@ -1,7 +1,15 @@ -{pkgs, ...}: { +{ + pkgs, + lib, + ... +}: { boot.zfs.devNodes = "/dev/disk/by-path"; environment.systemPackages = with pkgs; [ zfs ]; + + # Microvm be fucking shit up + # fileSystems."/nix/store".fsType = lib.mkForce "zfs"; + # fileSystems."/nix/store".device = lib.mkForce "zroot/nix/store"; }