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 <raviarnankeren@gmail.com>
This commit is contained in:
Ravi Arnan committed 2026-10-19 16:43:31 +08:00
1 parent 725ea35e41
commit 5c23390694
2 files changed
+22

No files matched your search

+1
View File
@@ -55,6 +55,7 @@ in
diskoBasedConfiguration
];
disko.enableConfig = false;
disko.testMode = true;
disko.imageBuilder.copyNixStore = false;
+21
View File
@@ -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 <nixpkgs> { },
...
}:
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"