From 15e7b32c2da163e5a6c3206cc4c5cd88dff4ef51 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Tue, 28 Jun 2022 00:08:28 +0200 Subject: [PATCH] fix VMs on nixos-22.05 --- examples/deploy-krops.sh | 6 ++++-- examples/deploy-qemu-vm.sh | 2 +- examples/qemu-vm/minimal-vm.nix | 10 +++++++--- examples/qemu-vm/vm-config.nix | 3 +++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/examples/deploy-krops.sh b/examples/deploy-krops.sh index cf7de7f..6cbd0e1 100755 --- a/examples/deploy-krops.sh +++ b/examples/deploy-krops.sh @@ -26,15 +26,17 @@ echo "Building the target VM" # Build the initial VM to which the nix-bitcoin node is deployed via krops nix-build --out-link $tmpDir/vm - <<'EOF' (import { - configuration = { lib, ... }: { + configuration = { config, lib, ... }: { imports = [ ]; services.openssh.enable = true; # Silence the following warning that appears when deploying via krops: # warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring nix.nixPath = lib.mkForce []; + + system.stateVersion = config.system.nixos.release; }; -}).vm +}).config.system.build.vm EOF vmNumCPUs=4 diff --git a/examples/deploy-qemu-vm.sh b/examples/deploy-qemu-vm.sh index 77869b2..53c971c 100755 --- a/examples/deploy-qemu-vm.sh +++ b/examples/deploy-qemu-vm.sh @@ -31,7 +31,7 @@ nix-build --out-link $tmpDir/vm - <<'EOF' ]; nix-bitcoin.generateSecrets = true; }; -}).vm +}).config.system.build.vm EOF vmNumCPUs=4 diff --git a/examples/qemu-vm/minimal-vm.nix b/examples/qemu-vm/minimal-vm.nix index eb89eb6..2c1f51a 100644 --- a/examples/qemu-vm/minimal-vm.nix +++ b/examples/qemu-vm/minimal-vm.nix @@ -13,19 +13,21 @@ rec { vm = (import "${nixpkgs}/nixos" { inherit system; - configuration = { lib, ... }: { + configuration = { config, lib, modulesPath, ... }: { imports = [ nix-bitcoin.nixosModules.default "${nix-bitcoin}/modules/presets/secure-node.nix" + "${modulesPath}/virtualisation/qemu-vm.nix" ]; + virtualisation.graphics = false; + nix-bitcoin.generateSecrets = true; services.clightning.enable = true; # For faster startup in offline VMs services.clightning.extraConfig = "disable-dns"; nixpkgs.pkgs = pkgs; - virtualisation.graphics = false; services.getty.autologinUser = "root"; nix.nixPath = [ "nixpkgs=${nixpkgs}" ]; @@ -42,8 +44,10 @@ rec { systemd.services."serial-getty@".preStop = '' echo o >/proc/sysrq-trigger ''; + + system.stateVersion = config.system.nixos.release; }; - }).vm; + }).config.system.build.vm; runVM = mkVMScript vm; } diff --git a/examples/qemu-vm/vm-config.nix b/examples/qemu-vm/vm-config.nix index df3d40c..28f8cd3 100644 --- a/examples/qemu-vm/vm-config.nix +++ b/examples/qemu-vm/vm-config.nix @@ -1,7 +1,10 @@ +{ modulesPath, ... }: { # Disable the hardened preset to improve VM performance disabledModules = [ ]; + imports = [ "${modulesPath}/virtualisation/qemu-vm.nix" ]; + config = { virtualisation.graphics = false; services.getty.autologinUser = "root";