From 244057cf9fe516aad51a689de8519daedf49dc97 Mon Sep 17 00:00:00 2001 From: Winter Date: Mon, 20 Jul 2026 20:23:26 -0400 Subject: [PATCH 1/2] nixos/lib/testing: `builtins.length (lib.attrNames ...) > 0 -> != to the empty set --- nixos/lib/testing/run.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nixos/lib/testing/run.nix b/nixos/lib/testing/run.nix index 0b35007f0c0b..b8a850489ffe 100644 --- a/nixos/lib/testing/run.nix +++ b/nixos/lib/testing/run.nix @@ -35,8 +35,7 @@ let options = { devnet = mkOption { type = types.bool; - default = - builtins.length (lib.attrNames containers) > 0 && builtins.length (lib.attrNames nodes) > 0; + default = containers != { } && nodes != { }; defaultText = lib.literalMD "`true` if both VMs and containers are present."; description = '' This heuristic setting that assumes that the majority of tests requires VMs and containers @@ -52,7 +51,7 @@ let }; uid-range = mkOption { type = types.bool; - default = builtins.length (lib.attrNames containers) > 0; + default = containers != { }; defaultText = lib.literalMD "`true` if containers are present."; description = "Containers use systemd-nspawn, which requires pid 0 inside of the sandbox. `uid-range` enables that."; }; From bb3215658765d60e8086585dfbcd10038599bfdb Mon Sep 17 00:00:00 2001 From: Winter Date: Fri, 3 Jul 2026 19:15:22 -0400 Subject: [PATCH 2/2] nixos/lib/testing: don't require kvm if only containers are specified Allows containers to be run on systems that don't have the `kvm` feature enabled, like VMs that don't support nested virt. --- nixos/lib/testing/run.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/lib/testing/run.nix b/nixos/lib/testing/run.nix index b8a850489ffe..f97489f67be5 100644 --- a/nixos/lib/testing/run.nix +++ b/nixos/lib/testing/run.nix @@ -57,8 +57,8 @@ let }; kvm = mkOption { type = types.bool; - default = isLinux; - defaultText = lib.literalMD "`true` if built to run on Linux."; + default = isLinux && nodes != { }; + defaultText = lib.literalMD "`true` if built to run on Linux and any virtual machines are specified."; description = "Whether Linux KVM virtualization is required when running this test. Can be disabled to allow emulated execution."; }; apple-virt = mkOption {