summary refs log tree commit diff
path: root/nixos/maintainers/scripts/ec2/amazon-image.nix
diff options
context:
space:
mode:
authorGraham Christensen <graham@grahamc.com>2021-08-25 09:38:55 -0400
committerGraham Christensen <graham@grahamc.com>2021-08-25 10:42:35 -0400
commit71b3d18181974523ef7264106a4bf213a3103439 (patch)
tree28c64e043bbfc0fb34f6c88bca15938db33a9de4 /nixos/maintainers/scripts/ec2/amazon-image.nix
parentbd38b059eae05871579b2dfd51cd41d058b6a1ec (diff)
downloadnixpkgs-71b3d18181974523ef7264106a4bf213a3103439.tar
nixpkgs-71b3d18181974523ef7264106a4bf213a3103439.tar.gz
nixpkgs-71b3d18181974523ef7264106a4bf213a3103439.tar.bz2
nixpkgs-71b3d18181974523ef7264106a4bf213a3103439.tar.lz
nixpkgs-71b3d18181974523ef7264106a4bf213a3103439.tar.xz
nixpkgs-71b3d18181974523ef7264106a4bf213a3103439.tar.zst
nixpkgs-71b3d18181974523ef7264106a4bf213a3103439.zip
amazon images: extend the image-info.json to have a disks object
Having a disks object with a dictionary of all the disks and their
properties makes it easier to process multi-disk images.

Note the rename of `label` to `system_label` is because `$label`i
is something of a special token to jq.
Diffstat (limited to 'nixos/maintainers/scripts/ec2/amazon-image.nix')
-rw-r--r--nixos/maintainers/scripts/ec2/amazon-image.nix24
1 files changed, 18 insertions, 6 deletions
diff --git a/nixos/maintainers/scripts/ec2/amazon-image.nix b/nixos/maintainers/scripts/ec2/amazon-image.nix
index cb9fbfd8603..6942b58f236 100644
--- a/nixos/maintainers/scripts/ec2/amazon-image.nix
+++ b/nixos/maintainers/scripts/ec2/amazon-image.nix
@@ -102,14 +102,20 @@ in {
         echo "file ${cfg.format} $rootDisk" >> $out/nix-support/hydra-build-products
 
        ${pkgs.jq}/bin/jq -n \
-         --arg label ${lib.escapeShellArg config.system.nixos.label} \
+         --arg system_label ${lib.escapeShellArg config.system.nixos.label} \
          --arg system ${lib.escapeShellArg pkgs.stdenv.hostPlatform.system} \
          --arg root_logical_bytes "$(${pkgs.qemu}/bin/qemu-img info --output json "$bootDisk" | ${pkgs.jq}/bin/jq '."virtual-size"')" \
          --arg boot_logical_bytes "$(${pkgs.qemu}/bin/qemu-img info --output json "$rootDisk" | ${pkgs.jq}/bin/jq '."virtual-size"')" \
          --arg root "$rootDisk" \
          --arg boot "$bootDisk" \
-         '$ARGS.named' \
-         > $out/nix-support/image-info.json
+        '{}
+          | .label = $system_label
+          | .system = $system
+          | .disks.boot.logical_bytes = $boot_logical_bytes
+          | .disks.boot.file = $boot
+          | .disks.root.logical_bytes = $root_logical_bytes
+          | .disks.root.file = $root
+          ' > $out/nix-support/image-info.json
       '';
     };
 
@@ -136,12 +142,18 @@ in {
         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_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
+          '{}
+          | .label = $system_label
+          | .system = $system
+          | .logical_bytes = $logical_bytes
+          | .file = $file
+          | .disks.root.logical_bytes = $logical_bytes
+          | .disks.root.file = $file
+          ' > $out/nix-support/image-info.json
       '';
     };
   in if config.ec2.zfs.enable then zfsBuilder else extBuilder;