Luke Granger-Brown
57725ef3ec
git-subtree-dir: third_party/nixpkgs git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
38 lines
1 KiB
Nix
38 lines
1 KiB
Nix
{ lib, config, ... }:
|
|
let
|
|
t = lib.types;
|
|
in
|
|
{
|
|
options = {
|
|
virtualisation.diskSizeAutoSupported = lib.mkOption {
|
|
type = t.bool;
|
|
default = true;
|
|
description = ''
|
|
Whether the current image builder or vm runner supports `virtualisation.diskSize = "auto".`
|
|
'';
|
|
internal = true;
|
|
};
|
|
|
|
virtualisation.diskSize = lib.mkOption {
|
|
type = t.either (t.enum [ "auto" ]) t.ints.positive;
|
|
default = if config.virtualisation.diskSizeAutoSupported then "auto" else 1024;
|
|
defaultText = "\"auto\" if diskSizeAutoSupported, else 1024";
|
|
description = ''
|
|
The disk size in megabytes of the virtual machine.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config =
|
|
let
|
|
inherit (config.virtualisation) diskSize diskSizeAutoSupported;
|
|
in
|
|
{
|
|
assertions = [
|
|
{
|
|
assertion = diskSize != "auto" || diskSizeAutoSupported;
|
|
message = "Setting virtualisation.diskSize to `auto` is not supported by the current image build or vm runner; use an explicit size.";
|
|
}
|
|
];
|
|
};
|
|
}
|