diff --git a/nixos/modules/virtualisation/azure-image.nix b/nixos/modules/virtualisation/azure-image.nix index fa09398e12f8..c3580274b4a6 100644 --- a/nixos/modules/virtualisation/azure-image.nix +++ b/nixos/modules/virtualisation/azure-image.nix @@ -67,6 +67,16 @@ in For v2, secure boot needs to be turned off during creation. ''; }; + + additionalSpace = mkOption { + type = types.str; + default = "512M"; + example = "2048M"; + description = '' + additional disk space to be added to the image if diskSize "auto" + is used. + ''; + }; }; config = { @@ -81,8 +91,12 @@ in # generating raw format and convert with subformat args afterwards format = "raw"; postVM = '' - ${pkgs.vmTools.qemu}/bin/qemu-img convert -f raw -o subformat=fixed,force_size -O vpc $diskImage $out/${config.image.fileName} + ${lib.getExe' pkgs.vmTools.qemu "qemu-img"} convert -f raw -o subformat=fixed,force_size -O vpc $diskImage $out/${config.image.fileName} rm $diskImage + '' + + lib.optionalString (cfg.diskSize == "auto") '' + truncate -s +${cfg.additionalSpace} "$out/${config.image.fileName}" + ${lib.getExe' pkgs.cloud-utils "growpart"} "$out/${config.image.fileName}" 1 ''; configFile = ./azure-config-user.nix;