Loading nixos/maintainers/scripts/ec2/amazon-image.nix +22 −12 Original line number Diff line number Diff line Loading @@ -15,11 +15,23 @@ let inherit (lib.options) literalExpression; cfg = config.amazonImage; amiBootMode = if config.ec2.efi then "uefi" else "legacy-bios"; in { imports = [ ../../../modules/virtualisation/amazon-image.nix ]; imports = [ ../../../modules/virtualisation/amazon-image.nix ../../../modules/virtualisation/disk-size-option.nix (lib.mkRenamedOptionModuleWith { sinceRelease = 2411; from = [ "amazonImage" "sizeMB" ]; to = [ "virtualisation" "diskSize" ]; }) ]; # Amazon recommends setting this to the highest possible value for a good EBS # experience, which prior to 4.15 was 255. Loading Loading @@ -52,13 +64,6 @@ in ''; }; sizeMB = mkOption { type = with types; either (enum [ "auto" ]) int; default = 3072; example = 8192; description = "The size in MB of the image"; }; format = mkOption { type = types.enum [ "raw" Loading @@ -70,6 +75,11 @@ in }; }; # Use a priority just below mkOptionDefault (1500) instead of lib.mkDefault # to avoid breaking existing configs using that. config.virtualisation.diskSize = lib.mkOverride 1490 (3 * 1024); config.virtualisation.diskSizeAutoSupported = !config.ec2.zfs.enable; config.system.build.amazonImage = let configFile = pkgs.writeText "configuration.nix" '' Loading Loading @@ -98,7 +108,7 @@ in bootSize = 1000; # 1G is the minimum EBS volume rootSize = cfg.sizeMB; rootSize = config.virtualisation.diskSize; rootPoolProperties = { ashift = 12; autoexpand = "on"; Loading Loading @@ -151,7 +161,7 @@ in fsType = "ext4"; partitionTableType = if config.ec2.efi then "efi" else "legacy+gpt"; diskSize = cfg.sizeMB; inherit (config.virtualisation) diskSize; postVM = '' extension=''${diskImage##*.} Loading nixos/maintainers/scripts/openstack/openstack-image-zfs.nix +19 −8 Original line number Diff line number Diff line Loading @@ -15,6 +15,18 @@ in { imports = [ ../../../modules/virtualisation/openstack-config.nix ../../../modules/virtualisation/disk-size-option.nix (lib.mkRenamedOptionModuleWith { sinceRelease = 2411; from = [ "openstackImage" "sizeMB" ]; to = [ "virtualisation" "diskSize" ]; }) ] ++ (lib.optional copyChannel ../../../modules/installer/cd-dvd/channel.nix); options.openstackImage = { Loading @@ -26,16 +38,10 @@ in ramMB = mkOption { type = types.int; default = 1024; default = (3 * 1024); description = "RAM allocation for build VM"; }; sizeMB = mkOption { type = types.int; default = 8192; description = "The size in MB of the image"; }; format = mkOption { type = types.enum [ "raw" Loading @@ -61,6 +67,11 @@ in }; }; # Use a priority just below mkOptionDefault (1500) instead of lib.mkDefault # to avoid breaking existing configs using that. virtualisation.diskSize = lib.mkOverride 1490 (8 * 1024); virtualisation.diskSizeAutoSupported = false; system.build.openstackImage = import ../../../lib/make-single-disk-zfs-image.nix { inherit lib config; inherit (cfg) contents format name; Loading @@ -77,7 +88,7 @@ in bootSize = 1000; memSize = cfg.ramMB; rootSize = cfg.sizeMB; rootSize = config.virtualisation.diskSize; rootPoolProperties = { ashift = 12; autoexpand = "on"; Loading nixos/modules/virtualisation/azure-image.nix +18 −11 Original line number Diff line number Diff line Loading @@ -10,18 +10,24 @@ let cfg = config.virtualisation.azureImage; in { imports = [ ./azure-common.nix ]; imports = [ ./azure-common.nix ./disk-size-option.nix (lib.mkRenamedOptionModuleWith { sinceRelease = 2411; from = [ "virtualisation" "azureImage" "diskSize" ]; to = [ "virtualisation" "diskSize" ]; }) ]; options.virtualisation.azureImage = { diskSize = mkOption { type = with types; either (enum [ "auto" ]) int; default = "auto"; example = 2048; description = '' Size of disk image. Unit is MB. ''; }; bootSize = mkOption { type = types.int; default = 256; Loading Loading @@ -67,7 +73,8 @@ in bootSize = "${toString cfg.bootSize}M"; partitionTableType = if cfg.vmGeneration == "v2" then "efi" else "legacy"; inherit (cfg) diskSize contents; inherit (cfg) contents; inherit (config.virtualisation) diskSize; inherit config lib pkgs; }; }; Loading nixos/modules/virtualisation/digital-ocean-image.nix +17 −12 Original line number Diff line number Diff line Loading @@ -11,18 +11,24 @@ let in { imports = [ ./digital-ocean-config.nix ]; imports = [ ./digital-ocean-config.nix ./disk-size-option.nix (lib.mkRenamedOptionModuleWith { sinceRelease = 2411; from = [ "virtualisation" "digitalOceanImage" "diskSize" ]; to = [ "virtualisation" "diskSize" ]; }) ]; options = { virtualisation.digitalOceanImage.diskSize = mkOption { type = with types; either (enum [ "auto" ]) int; default = "auto"; example = 4096; description = '' Size of disk image. Unit is MB. ''; }; virtualisation.digitalOceanImage.configFile = mkOption { type = with types; nullOr path; default = null; Loading Loading @@ -52,7 +58,6 @@ in #### implementation config = { system.build.digitalOceanImage = import ../../lib/make-disk-image.nix { name = "digital-ocean-image"; format = "qcow2"; Loading @@ -73,7 +78,7 @@ in config.virtualisation.digitalOcean.defaultConfigFile else cfg.configFile; inherit (cfg) diskSize; inherit (config.virtualisation) diskSize; inherit config lib pkgs; }; Loading nixos/modules/virtualisation/disk-size-option.nix 0 → 100644 +38 −0 Original line number Diff line number Diff line { 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."; } ]; }; } Loading
nixos/maintainers/scripts/ec2/amazon-image.nix +22 −12 Original line number Diff line number Diff line Loading @@ -15,11 +15,23 @@ let inherit (lib.options) literalExpression; cfg = config.amazonImage; amiBootMode = if config.ec2.efi then "uefi" else "legacy-bios"; in { imports = [ ../../../modules/virtualisation/amazon-image.nix ]; imports = [ ../../../modules/virtualisation/amazon-image.nix ../../../modules/virtualisation/disk-size-option.nix (lib.mkRenamedOptionModuleWith { sinceRelease = 2411; from = [ "amazonImage" "sizeMB" ]; to = [ "virtualisation" "diskSize" ]; }) ]; # Amazon recommends setting this to the highest possible value for a good EBS # experience, which prior to 4.15 was 255. Loading Loading @@ -52,13 +64,6 @@ in ''; }; sizeMB = mkOption { type = with types; either (enum [ "auto" ]) int; default = 3072; example = 8192; description = "The size in MB of the image"; }; format = mkOption { type = types.enum [ "raw" Loading @@ -70,6 +75,11 @@ in }; }; # Use a priority just below mkOptionDefault (1500) instead of lib.mkDefault # to avoid breaking existing configs using that. config.virtualisation.diskSize = lib.mkOverride 1490 (3 * 1024); config.virtualisation.diskSizeAutoSupported = !config.ec2.zfs.enable; config.system.build.amazonImage = let configFile = pkgs.writeText "configuration.nix" '' Loading Loading @@ -98,7 +108,7 @@ in bootSize = 1000; # 1G is the minimum EBS volume rootSize = cfg.sizeMB; rootSize = config.virtualisation.diskSize; rootPoolProperties = { ashift = 12; autoexpand = "on"; Loading Loading @@ -151,7 +161,7 @@ in fsType = "ext4"; partitionTableType = if config.ec2.efi then "efi" else "legacy+gpt"; diskSize = cfg.sizeMB; inherit (config.virtualisation) diskSize; postVM = '' extension=''${diskImage##*.} Loading
nixos/maintainers/scripts/openstack/openstack-image-zfs.nix +19 −8 Original line number Diff line number Diff line Loading @@ -15,6 +15,18 @@ in { imports = [ ../../../modules/virtualisation/openstack-config.nix ../../../modules/virtualisation/disk-size-option.nix (lib.mkRenamedOptionModuleWith { sinceRelease = 2411; from = [ "openstackImage" "sizeMB" ]; to = [ "virtualisation" "diskSize" ]; }) ] ++ (lib.optional copyChannel ../../../modules/installer/cd-dvd/channel.nix); options.openstackImage = { Loading @@ -26,16 +38,10 @@ in ramMB = mkOption { type = types.int; default = 1024; default = (3 * 1024); description = "RAM allocation for build VM"; }; sizeMB = mkOption { type = types.int; default = 8192; description = "The size in MB of the image"; }; format = mkOption { type = types.enum [ "raw" Loading @@ -61,6 +67,11 @@ in }; }; # Use a priority just below mkOptionDefault (1500) instead of lib.mkDefault # to avoid breaking existing configs using that. virtualisation.diskSize = lib.mkOverride 1490 (8 * 1024); virtualisation.diskSizeAutoSupported = false; system.build.openstackImage = import ../../../lib/make-single-disk-zfs-image.nix { inherit lib config; inherit (cfg) contents format name; Loading @@ -77,7 +88,7 @@ in bootSize = 1000; memSize = cfg.ramMB; rootSize = cfg.sizeMB; rootSize = config.virtualisation.diskSize; rootPoolProperties = { ashift = 12; autoexpand = "on"; Loading
nixos/modules/virtualisation/azure-image.nix +18 −11 Original line number Diff line number Diff line Loading @@ -10,18 +10,24 @@ let cfg = config.virtualisation.azureImage; in { imports = [ ./azure-common.nix ]; imports = [ ./azure-common.nix ./disk-size-option.nix (lib.mkRenamedOptionModuleWith { sinceRelease = 2411; from = [ "virtualisation" "azureImage" "diskSize" ]; to = [ "virtualisation" "diskSize" ]; }) ]; options.virtualisation.azureImage = { diskSize = mkOption { type = with types; either (enum [ "auto" ]) int; default = "auto"; example = 2048; description = '' Size of disk image. Unit is MB. ''; }; bootSize = mkOption { type = types.int; default = 256; Loading Loading @@ -67,7 +73,8 @@ in bootSize = "${toString cfg.bootSize}M"; partitionTableType = if cfg.vmGeneration == "v2" then "efi" else "legacy"; inherit (cfg) diskSize contents; inherit (cfg) contents; inherit (config.virtualisation) diskSize; inherit config lib pkgs; }; }; Loading
nixos/modules/virtualisation/digital-ocean-image.nix +17 −12 Original line number Diff line number Diff line Loading @@ -11,18 +11,24 @@ let in { imports = [ ./digital-ocean-config.nix ]; imports = [ ./digital-ocean-config.nix ./disk-size-option.nix (lib.mkRenamedOptionModuleWith { sinceRelease = 2411; from = [ "virtualisation" "digitalOceanImage" "diskSize" ]; to = [ "virtualisation" "diskSize" ]; }) ]; options = { virtualisation.digitalOceanImage.diskSize = mkOption { type = with types; either (enum [ "auto" ]) int; default = "auto"; example = 4096; description = '' Size of disk image. Unit is MB. ''; }; virtualisation.digitalOceanImage.configFile = mkOption { type = with types; nullOr path; default = null; Loading Loading @@ -52,7 +58,6 @@ in #### implementation config = { system.build.digitalOceanImage = import ../../lib/make-disk-image.nix { name = "digital-ocean-image"; format = "qcow2"; Loading @@ -73,7 +78,7 @@ in config.virtualisation.digitalOcean.defaultConfigFile else cfg.configFile; inherit (cfg) diskSize; inherit (config.virtualisation) diskSize; inherit config lib pkgs; }; Loading
nixos/modules/virtualisation/disk-size-option.nix 0 → 100644 +38 −0 Original line number Diff line number Diff line { 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."; } ]; }; }