From 5c2339069443bf9856453c7fc266124bee33cb0a Mon Sep 17 00:00:00 2001 From: Ravi Arnan Date: Mon, 19 Oct 2026 16:43:31 +0800 Subject: [PATCH] interactive-vm: disable disko.enableConfig to avoid duplicate swapDevices When building `vmWithDisko` via `extendModules`, the outer `module.nix` is evaluated with `disko.enableConfig = true` (default), contributing `swapDevices = cfg.devices._config.swapDevices or [ ]`. At the same time, `interactive-vm.nix` contributes `cfg_.disko.devices._config.swapDevices` via `diskoBasedConfiguration`. Because `swapDevices` in NixOS is a `listOf submodule`, definitions are merged by concatenation, causing every swap device from the disko config to appear twice in the generated fstab. During boot, `systemd-fstab-generator` then fails with exit status 1 due to conflicting generated swap units. Setting `disko.enableConfig = false` in `interactive-vm.nix` prevents the outer module from injecting unmapped host disko configurations, while allowing `interactive-vm.nix` to supply the QEMU-mapped devices cleanly. Closes #1283 Signed-off-by: Ravi Arnan --- lib/interactive-vm.nix | 1 + tests/vm-with-disko-swap.nix | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/vm-with-disko-swap.nix diff --git a/lib/interactive-vm.nix b/lib/interactive-vm.nix index 2ac3df6..f60d156 100644 --- a/lib/interactive-vm.nix +++ b/lib/interactive-vm.nix @@ -55,6 +55,7 @@ in diskoBasedConfiguration ]; + disko.enableConfig = false; disko.testMode = true; disko.imageBuilder.copyNixStore = false; diff --git a/tests/vm-with-disko-swap.nix b/tests/vm-with-disko-swap.nix new file mode 100644 index 0000000..16f6b4c --- /dev/null +++ b/tests/vm-with-disko-swap.nix @@ -0,0 +1,21 @@ +# vmWithDisko must not duplicate swapDevices generated from the disko config. +# Regression test for https://github.com/nix-community/disko/issues/1283 +{ + pkgs ? import { }, + ... +}: +let + lib = pkgs.lib; + system = pkgs.nixos [ + ../module.nix + ../example/swap.nix + { + documentation.enable = false; + system.stateVersion = "26.11"; + } + ]; + vmSwap = system.config.virtualisation.vmVariantWithDisko.swapDevices; + uniqueSwapDevices = lib.unique (map (s: s.device) vmSwap); +in +assert (builtins.length vmSwap == builtins.length uniqueSwapDevices); +pkgs.runCommand "test-vm-with-disko-swap" { } "touch $out"