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.
This commit is contained in:
Robert Hensing 2025-03-17 17:45:12 +00:00
parent 527fcd5419
commit 9aab8b86c7

View file

@ -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