···13131414rm -f ec2-amis.nix
15151616+types="hvm pv"
1717+stores="ebs s3"
1818+regions="eu-west-1 eu-central-1 us-east-1 us-west-1 us-west-2 ap-southeast-1 ap-southeast-2 ap-northeast-1 sa-east-1"
16191717-for type in hvm pv; do
2020+for type in $types; do
1821 link=$stateDir/$type
1922 imageFile=$link/nixos.qcow2
2023 system=x86_64-linux
···3134 --arg configuration "{ imports = [ <nixpkgs/nixos/maintainers/scripts/ec2/amazon-image.nix> ]; ec2.hvm = $hvmFlag; }"
3235 fi
33363434- for store in ebs s3; do
3737+ for store in $stores; do
35383639 bucket=nixos-amis
3740 bucketDir="$version-$type-$store"
···3942 prevAmi=
4043 prevRegion=
41444242- for region in eu-west-1 eu-central-1 us-east-1 us-west-1 us-west-2 ap-southeast-1 ap-southeast-2 ap-northeast-1 sa-east-1; do
4545+ for region in $regions; do
43464447 name=nixos-$version-$arch-$type-$store
4548 description="NixOS $system $version ($type-$store)"
···226229227230 echo "region = $region, type = $type, store = $store, ami = $ami"
228231229229- if [ -z "$NO_WAIT" -o -z "$prevAmi" ]; then
230230- echo -n "waiting for AMI..."
231231- while true; do
232232- status=$(aws ec2 describe-images --image-ids "$ami" --region "$region" | jq -r .Images[0].State)
233233- if [ "$status" = available ]; then break; fi
234234- sleep 10
235235- echo -n '.'
236236- done
237237- echo
238238-239239- # Make the image public.
240240- aws ec2 modify-image-attribute \
241241- --image-id "$ami" --region "$region" --launch-permission 'Add={Group=all}'
242242- fi
243243-244232 if [ -z "$prevAmi" ]; then
245233 prevAmi="$ami"
246234 prevRegion="$region"
247235 fi
236236+ done
237237+238238+ done
239239+240240+done
241241+242242+for type in $types; do
243243+ link=$stateDir/$type
244244+ system=x86_64-linux
245245+ arch=x86_64
246246+247247+ for store in $stores; do
248248+249249+ for region in $regions; do
250250+251251+ name=nixos-$version-$arch-$type-$store
252252+ amiFile=$stateDir/$region.$type.$store.ami-id
253253+ ami=$(cat $amiFile)
254254+255255+ echo "region = $region, type = $type, store = $store, ami = $ami"
256256+257257+ echo -n "waiting for AMI..."
258258+ while true; do
259259+ status=$(aws ec2 describe-images --image-ids "$ami" --region "$region" | jq -r .Images[0].State)
260260+ if [ "$status" = available ]; then break; fi
261261+ sleep 10
262262+ echo -n '.'
263263+ done
264264+ echo
265265+266266+ # Make the image public.
267267+ aws ec2 modify-image-attribute \
268268+ --image-id "$ami" --region "$region" --launch-permission 'Add={Group=all}'
248269249270 echo " \"$major\".$region.$type-$store = \"$ami\";" >> ec2-amis.nix
250271 done