edk2, OVMF: Build on aarch64

And also build in parallel.

I don't understand why we manually tediously link every single directory
from the source, but I don't want to investigate too much.

+33 -11
+30 -10
pkgs/applications/virtualization/OVMF/default.nix
··· 2 2 3 3 let 4 4 5 - targetArch = if stdenv.isi686 then 6 - "Ia32" 5 + projectDscPath = if stdenv.isi686 then 6 + "OvmfPkg/OvmfPkgIa32.dsc" 7 7 else if stdenv.isx86_64 then 8 - "X64" 8 + "OvmfPkg/OvmfPkgX64.dsc" 9 + else if stdenv.isAarch64 then 10 + "ArmVirtPkg/ArmVirtQemu.dsc" 9 11 else 10 12 throw "Unsupported architecture"; 11 13 ··· 14 16 src = edk2.src; 15 17 in 16 18 17 - stdenv.mkDerivation (edk2.setup "OvmfPkg/OvmfPkg${targetArch}.dsc" { 19 + stdenv.mkDerivation (edk2.setup projectDscPath { 18 20 name = "OVMF-${version}"; 19 21 20 22 inherit src; ··· 36 38 ln -sv "$file" . 37 39 done 38 40 39 - ${if seabios != null then '' 41 + ${if stdenv.isAarch64 then '' 42 + ln -sv ${src}/ArmPkg . 43 + ln -sv ${src}/ArmPlatformPkg . 44 + ln -sv ${src}/ArmVirtPkg . 45 + ln -sv ${src}/EmbeddedPkg . 46 + ln -sv ${src}/OvmfPkg . 47 + '' else if seabios != null then '' 40 48 cp -r ${src}/OvmfPkg . 41 49 chmod +w OvmfPkg/Csm/Csm16 42 50 cp ${seabios}/Csm16.bin OvmfPkg/Csm/Csm16/Csm16.bin ··· 50 58 ''} 51 59 ''; 52 60 53 - buildPhase = if seabios == null then '' 54 - build ${lib.optionalString secureBoot "-DSECURE_BOOT_ENABLE=TRUE"} 61 + buildPhase = if stdenv.isAarch64 then '' 62 + build -n $NIX_BUILD_CORES 63 + '' else if seabios == null then '' 64 + build -n $NIX_BUILD_CORES ${lib.optionalString secureBoot "-DSECURE_BOOT_ENABLE=TRUE"} 55 65 '' else '' 56 - build -D CSM_ENABLE -D FD_SIZE_2MB ${lib.optionalString secureBoot "-DSECURE_BOOT_ENABLE=TRUE"} 66 + build -n $NIX_BUILD_CORES -D CSM_ENABLE -D FD_SIZE_2MB ${lib.optionalString secureBoot "-DSECURE_BOOT_ENABLE=TRUE"} 57 67 ''; 58 68 59 - postFixup = '' 69 + postFixup = if stdenv.isAarch64 then '' 70 + mkdir -vp $fd/FV 71 + mkdir -vp $fd/AAVMF 72 + mv -v $out/FV/QEMU_{EFI,VARS}.fd $fd/FV 73 + 74 + # Uses Fedora dir layout: https://src.fedoraproject.org/cgit/rpms/edk2.git/tree/edk2.spec 75 + # FIXME: why is it different from Debian dir layout? https://anonscm.debian.org/cgit/pkg-qemu/edk2.git/tree/debian/rules 76 + dd of=$fd/AAVMF/QEMU_EFI-pflash.raw if=/dev/zero bs=1M count=64 77 + dd of=$fd/AAVMF/QEMU_EFI-pflash.raw if=$fd/FV/QEMU_EFI.fd conv=notrunc 78 + dd of=$fd/AAVMF/vars-template-pflash.raw if=/dev/zero bs=1M count=64 79 + '' else '' 60 80 mkdir -vp $OUTPUT_FD/FV 61 81 mv -v $out/FV/OVMF{,_CODE,_VARS}.fd $OUTPUT_FD/FV 62 82 ''; ··· 67 87 description = "Sample UEFI firmware for QEMU and KVM"; 68 88 homepage = https://sourceforge.net/apps/mediawiki/tianocore/index.php?title=OVMF; 69 89 license = stdenv.lib.licenses.bsd2; 70 - platforms = ["x86_64-linux" "i686-linux"]; 90 + platforms = ["x86_64-linux" "i686-linux" "aarch64-linux"]; 71 91 }; 72 92 })
+3 -1
pkgs/development/compilers/edk2/default.nix
··· 7 7 "IA32" 8 8 else if stdenv.isx86_64 then 9 9 "X64" 10 + else if stdenv.isAarch64 then 11 + "AARCH64" 10 12 else 11 13 throw "Unsupported architecture"; 12 14 ··· 48 50 homepage = https://sourceforge.net/projects/edk2/; 49 51 license = stdenv.lib.licenses.bsd2; 50 52 branch = "UDK2017"; 51 - platforms = ["x86_64-linux" "i686-linux"]; 53 + platforms = ["x86_64-linux" "i686-linux" "aarch64-linux"]; 52 54 }; 53 55 54 56 passthru = {