From 9aab8b86c708f7e0e2b5e83a18c304e83a227b92 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 17 Mar 2025 17:45:12 +0000 Subject: [PATCH] nixos: Cut off virtualisation.vmVariant.virtualisation.vmVariant This produced an unnecessarily infinitely deep config tree. The "cut off" option can be written to, but not read from. Being written to is important, because it allows users to conveniently define vmVariant config without having to check isVmVariant. There's a small chance that someone *reads* from vmVariant config in their normal config, and for them it will not be possible to evaluate with `nixos-rebuild build-vm` anymore. If this is a problem, we could perhaps make the vmVariant root appear instead of the `throw` error. This could also be done using mkOption apply. --- nixos/modules/virtualisation/build-vm.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nixos/modules/virtualisation/build-vm.nix b/nixos/modules/virtualisation/build-vm.nix index b9db26b78c23..76b9c1b6227a 100644 --- a/nixos/modules/virtualisation/build-vm.nix +++ b/nixos/modules/virtualisation/build-vm.nix @@ -58,6 +58,18 @@ in vmWithBootLoader = lib.mkDefault config.virtualisation.vmVariantWithBootLoader.system.build.vm; }; + virtualisation.vmVariant = { + options = { + virtualisation.vmVariant = lib.mkOption { + apply = _: throw "virtualisation.vmVariant*.virtualisation.vmVariant is not supported"; + }; + virtualisation.vmVariantWithBootLoader = lib.mkOption { + apply = + _: throw "virtualisation.vmVariant*.virtualisation.vmVariantWithBootloader is not supported"; + }; + }; + }; + }; # uses extendModules