1{ config, lib, pkgs, ... }:
2
3with lib;
4let
5 cfg = config.virtualisation.azureImage;
6in
7{
8 imports = [ ./azure-common.nix ];
9
10 options = {
11 virtualisation.azureImage.diskSize = mkOption {
12 type = with types; either (enum [ "auto" ]) int;
13 default = "auto";
14 example = 2048;
15 description = ''
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 = ''
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 };
39
40 };
41}