diff options
Diffstat (limited to 'nixos/maintainers/scripts/ec2/amazon-image.nix')
-rw-r--r-- | nixos/maintainers/scripts/ec2/amazon-image.nix | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/nixos/maintainers/scripts/ec2/amazon-image.nix b/nixos/maintainers/scripts/ec2/amazon-image.nix index 88d95e67544..31e15537179 100644 --- a/nixos/maintainers/scripts/ec2/amazon-image.nix +++ b/nixos/maintainers/scripts/ec2/amazon-image.nix @@ -17,7 +17,7 @@ in { name = mkOption { type = types.str; description = "The name of the generated derivation"; - default = "nixos-disk-image"; + default = "nixos-amazon-image-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}"; }; contents = mkOption { @@ -42,7 +42,7 @@ in { format = mkOption { type = types.enum [ "raw" "qcow2" "vpc" ]; - default = "qcow2"; + default = "vpc"; description = "The image format to output"; }; }; @@ -51,7 +51,9 @@ in { inherit lib config; inherit (cfg) contents format name; pkgs = import ../../../.. { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package - partitionTableType = if config.ec2.hvm then "legacy" else "none"; + partitionTableType = if config.ec2.efi then "efi" + else if config.ec2.hvm then "legacy" + else "none"; diskSize = cfg.sizeMB; fsType = "ext4"; configFile = pkgs.writeText "configuration.nix" @@ -61,7 +63,27 @@ in { ${optionalString config.ec2.hvm '' ec2.hvm = true; ''} + ${optionalString config.ec2.efi '' + ec2.efi = true; + ''} } ''; + postVM = '' + extension=''${diskImage##*.} + friendlyName=$out/${cfg.name}.$extension + mv "$diskImage" "$friendlyName" + diskImage=$friendlyName + + mkdir -p $out/nix-support + echo "file ${cfg.format} $diskImage" >> $out/nix-support/hydra-build-products + + ${pkgs.jq}/bin/jq -n \ + --arg label ${lib.escapeShellArg config.system.nixos.label} \ + --arg system ${lib.escapeShellArg pkgs.stdenv.hostPlatform.system} \ + --arg logical_bytes "$(${pkgs.qemu}/bin/qemu-img info --output json "$diskImage" | ${pkgs.jq}/bin/jq '."virtual-size"')" \ + --arg file "$diskImage" \ + '$ARGS.named' \ + > $out/nix-support/image-info.json + ''; }; } |