mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 13:03:28 +01:00
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>
22 lines
636 B
Nix
22 lines
636 B
Nix
# 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"
|