Skip to content

Commit fec163d

Browse files
committed
qemu-vm: add EFI support for aarch64
1 parent d7e3312 commit fec163d

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

nixos/modules/virtualisation/qemu-vm.nix

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ let
8181

8282
drivesCmdLine = drives: concatStringsSep " " (imap1 driveCmdline drives);
8383

84+
8485
# Creates a device name from a 1-based a numerical index, e.g.
8586
# * `driveDeviceName 1` -> `/dev/vda`
8687
# * `driveDeviceName 2` -> `/dev/vdb`
@@ -99,7 +100,10 @@ let
99100
addDeviceNames =
100101
imap1 (idx: drive: drive // { device = driveDeviceName idx; });
101102

102-
efiPrefix = "${pkgs.OVMF.fd}/FV/OVMF";
103+
efiPrefix =
104+
if (pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64) then "${pkgs.OVMF.fd}/FV/OVMF"
105+
else if pkgs.stdenv.isAarch64 then "${pkgs.OVMF.fd}/FV/AAVMF"
106+
else throw "No EFI firmware available for platform";
103107
efiFirmware = "${efiPrefix}_CODE.fd";
104108
efiVars = "${efiPrefix}_VARS.fd";
105109

@@ -176,7 +180,7 @@ let
176180
''
177181
mkdir $out
178182
diskImage=$out/disk.img
179-
${qemu}/bin/qemu-img create -f qcow2 $diskImage "40M"
183+
${qemu}/bin/qemu-img create -f qcow2 $diskImage "60M"
180184
${if cfg.useEFIBoot then ''
181185
efiVars=$out/EFI_VARS.fd
182186
cp ${efiVars} $efiVars
@@ -191,7 +195,7 @@ let
191195
+ " -drive if=pflash,format=raw,unit=1,file=$efiVars");
192196
}
193197
''
194-
# Create a /boot EFI partition with 40M and arbitrary but fixed GUIDs for reproducibility
198+
# Create a /boot EFI partition with 60M and arbitrary but fixed GUIDs for reproducibility
195199
${pkgs.gptfdisk}/bin/sgdisk \
196200
--set-alignment=1 --new=1:34:2047 --change-name=1:BIOSBootPartition --typecode=1:ef02 \
197201
--set-alignment=512 --largest-new=2 --change-name=2:EFISystem --typecode=2:ef00 \

0 commit comments

Comments
 (0)