mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-26 07:34:11 +00:00
c6da9ef32d
See https://github.com/NixOS/nixpkgs/pull/339535 and https://github.com/NixOS/nixpkgs/pull/341058
39 lines
1.0 KiB
Nix
39 lines
1.0 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.";
|
|
}
|
|
];
|
|
};
|
|
}
|