Release NixOS 23.11
[NixPkgs.git] / nixos / modules / virtualisation / azure-image.nix
blobd909680cca1ff2d27f8a662c1e43be26aa8e5a98
1 { config, lib, pkgs, ... }:
3 with lib;
4 let
5   cfg = config.virtualisation.azureImage;
6 in
8   imports = [ ./azure-common.nix ];
10   options = {
11     virtualisation.azureImage.diskSize = mkOption {
12       type = with types; either (enum [ "auto" ]) int;
13       default = "auto";
14       example = 2048;
15       description = lib.mdDoc ''
16         Size of disk image. Unit is MB.
17       '';
18     };
19     virtualisation.azureImage.contents = mkOption {
20       type = with types; listOf attrs;
21       default = [ ];
22       description = lib.mdDoc ''
23         Extra contents to add to the image.
24       '';
25     };
26   };
27   config = {
28     system.build.azureImage = import ../../lib/make-disk-image.nix {
29       name = "azure-image";
30       postVM = ''
31         ${pkgs.vmTools.qemu}/bin/qemu-img convert -f raw -o subformat=fixed,force_size -O vpc $diskImage $out/disk.vhd
32         rm $diskImage
33       '';
34       configFile = ./azure-config-user.nix;
35       format = "raw";
36       inherit (cfg) diskSize contents;
37       inherit config lib pkgs;
38     };
40   };