1{ lib, config, ... }:
2let
3 t = lib.types;
4in
5{
6 options = {
7 virtualisation.diskSizeAutoSupported = lib.mkOption {
8 type = t.bool;
9 default = true;
10 description = ''
11 Whether the current image builder or vm runner supports `virtualisation.diskSize = "auto".`
12 '';
13 internal = true;
14 };
15
16 virtualisation.diskSize = lib.mkOption {
17 type = t.either (t.enum [ "auto" ]) t.ints.positive;
18 default = if config.virtualisation.diskSizeAutoSupported then "auto" else 1024;
19 defaultText = lib.literalExpression "if virtualisation.diskSizeAutoSupported then \"auto\" else 1024";
20 description = ''
21 The disk size in megabytes of the virtual machine.
22 '';
23 };
24 };
25
26 config =
27 let
28 inherit (config.virtualisation) diskSize diskSizeAutoSupported;
29 in
30 {
31 assertions = [
32 {
33 assertion = diskSize != "auto" || diskSizeAutoSupported;
34 message = "Setting virtualisation.diskSize to `auto` is not supported by the current image build or vm runner; use an explicit size.";
35 }
36 ];
37 };
38}