From a14985cd2844187bd3441d1179abe5f478caedd8 Mon Sep 17 00:00:00 2001 From: ajs124 Date: Tue, 25 May 2021 21:10:54 +0300 Subject: [PATCH 1/4] ipxe: allow building on aarch64 --- pkgs/tools/misc/ipxe/default.nix | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pkgs/tools/misc/ipxe/default.nix b/pkgs/tools/misc/ipxe/default.nix index 641e86c22c4b..289f87dc784d 100644 --- a/pkgs/tools/misc/ipxe/default.nix +++ b/pkgs/tools/misc/ipxe/default.nix @@ -1,4 +1,5 @@ -{ stdenv, lib, fetchFromGitHub, perl, cdrkit, syslinux, xz, openssl, gnu-efi, mtools +{ stdenv, lib, fetchFromGitHub, perl, cdrkit, xz, openssl, gnu-efi, mtools +, syslinux ? null , embedScript ? null , additionalTargets ? {} }: @@ -8,12 +9,20 @@ let "bin-x86_64-efi/ipxe.efi" = null; "bin-x86_64-efi/ipxe.efirom" = null; "bin-x86_64-efi/ipxe.usb" = "ipxe-efi.usb"; - } // { + } // lib.optionalAttrs (stdenv.isi686 || stdenv.isx86_64) { "bin/ipxe.dsk" = null; "bin/ipxe.usb" = null; "bin/ipxe.iso" = null; "bin/ipxe.lkrn" = null; "bin/undionly.kpxe" = null; + } // lib.optionalAttrs stdenv.isAarch32 { + "bin-arm32-efi/ipxe.efi" = null; + "bin-arm32-efi/ipxe.efirom" = null; + "bin-arm32-efi/ipxe.usb" = "ipxe-efi.usb"; + } // lib.optionalAttrs stdenv.isAarch64 { + "bin-arm64-efi/ipxe.efi" = null; + "bin-arm64-efi/ipxe.efirom" = null; + "bin-arm64-efi/ipxe.usb" = "ipxe-efi.usb"; }; in @@ -21,7 +30,7 @@ stdenv.mkDerivation rec { pname = "ipxe"; version = "1.21.1"; - nativeBuildInputs = [ perl cdrkit syslinux xz openssl gnu-efi mtools ]; + nativeBuildInputs = [ perl cdrkit xz openssl gnu-efi mtools ] ++ lib.optional (stdenv.isi686 || stdenv.isx86_64) syslinux; src = fetchFromGitHub { owner = "ipxe"; @@ -37,6 +46,7 @@ stdenv.mkDerivation rec { makeFlags = [ "ECHO_E_BIN_ECHO=echo" "ECHO_E_BIN_ECHO_E=echo" # No /bin/echo here. + ] ++ lib.optionals (stdenv.isi686 || stdenv.isx86_64) [ "ISOLINUX_BIN_LIST=${syslinux}/share/syslinux/isolinux.bin" "LDLINUX_C32=${syslinux}/share/syslinux/ldlinux.c32" ] ++ lib.optional (embedScript != null) "EMBED=${embedScript}"; @@ -80,6 +90,6 @@ stdenv.mkDerivation rec { homepage = "https://ipxe.org/"; license = licenses.gpl2; maintainers = with maintainers; [ ehmry ]; - platforms = [ "x86_64-linux" "i686-linux" ]; + platforms = platforms.linux; }; } From 2668c7588635db4abf51d68ba25bd00dcc78b8df Mon Sep 17 00:00:00 2001 From: misuzu Date: Wed, 14 Jul 2021 12:46:41 +0300 Subject: [PATCH 2/4] ipxe: fix installPhase and license --- pkgs/tools/misc/ipxe/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/misc/ipxe/default.nix b/pkgs/tools/misc/ipxe/default.nix index 289f87dc784d..4be0b3d417e4 100644 --- a/pkgs/tools/misc/ipxe/default.nix +++ b/pkgs/tools/misc/ipxe/default.nix @@ -72,6 +72,8 @@ stdenv.mkDerivation rec { buildFlags = lib.attrNames targets; installPhase = '' + runHook preInstall + mkdir -p $out ${lib.concatStringsSep "\n" (lib.mapAttrsToList (from: to: if to == null @@ -81,6 +83,8 @@ stdenv.mkDerivation rec { # Some PXE constellations especially with dnsmasq are looking for the file with .0 ending # let's provide it as a symlink to be compatible in this case. ln -s undionly.kpxe $out/undionly.kpxe.0 + + runHook postInstall ''; enableParallelBuilding = true; @@ -88,7 +92,7 @@ stdenv.mkDerivation rec { meta = with lib; { description = "Network boot firmware"; homepage = "https://ipxe.org/"; - license = licenses.gpl2; + license = licenses.gpl2Only; maintainers = with maintainers; [ ehmry ]; platforms = platforms.linux; }; From 702a1c23a46bfe7f1463f4c51a9121cb7bf8d441 Mon Sep 17 00:00:00 2001 From: misuzu Date: Tue, 25 May 2021 21:12:46 +0300 Subject: [PATCH 3/4] nixos/test-driver: allow overriding qemu binary in create_startcommand --- nixos/lib/test-driver/test-driver.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py index 7f4dd5963c92..15eaba88476f 100644 --- a/nixos/lib/test-driver/test-driver.py +++ b/nixos/lib/test-driver/test-driver.py @@ -292,7 +292,12 @@ class Machine: net_frontend += "," + args["netFrontendArgs"] start_command = ( - "qemu-kvm -m 384 " + net_backend + " " + net_frontend + " $QEMU_OPTS " + args.get("qemuBinary", "qemu-kvm") + + " -m 384 " + + net_backend + + " " + + net_frontend + + " $QEMU_OPTS " ) if "hda" in args: From 930daac3457de208e032f684c461c9354457055b Mon Sep 17 00:00:00 2001 From: misuzu Date: Tue, 25 May 2021 21:13:29 +0300 Subject: [PATCH 4/4] nixos/boot: test on aarch64 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/boot.nix | 42 +++++++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 2e4913dca478..76e5077f42d5 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -43,7 +43,7 @@ in bitcoind = handleTest ./bitcoind.nix {}; bittorrent = handleTest ./bittorrent.nix {}; blockbook-frontend = handleTest ./blockbook-frontend.nix {}; - boot = handleTestOn ["x86_64-linux"] ./boot.nix {}; # syslinux is unsupported on aarch64 + boot = handleTestOn ["x86_64-linux" "aarch64-linux"] ./boot.nix {}; boot-stage1 = handleTest ./boot-stage1.nix {}; borgbackup = handleTest ./borgbackup.nix {}; botamusique = handleTest ./botamusique.nix {}; diff --git a/nixos/tests/boot.nix b/nixos/tests/boot.nix index c5040f3b31fb..bdae6341ec91 100644 --- a/nixos/tests/boot.nix +++ b/nixos/tests/boot.nix @@ -4,6 +4,7 @@ }: with import ../lib/testing-python.nix { inherit system pkgs; }; +with import ../lib/qemu-flags.nix { inherit pkgs; }; with pkgs.lib; let @@ -21,7 +22,10 @@ let makeBootTest = name: extraConfig: let - machineConfig = pythonDict ({ qemuFlags = "-m 768"; } // extraConfig); + machineConfig = pythonDict ({ + qemuBinary = qemuBinary pkgs.qemu_test; + qemuFlags = "-m 768"; + } // extraConfig); in makeTest { inherit iso; @@ -61,6 +65,7 @@ let ]; }; machineConfig = pythonDict ({ + qemuBinary = qemuBinary pkgs.qemu_test; qemuFlags = "-boot order=n -m 2000"; netBackendArgs = "tftp=${ipxeBootDir},bootfile=netboot.ipxe"; } // extraConfig); @@ -75,8 +80,27 @@ let machine.shutdown() ''; }; + uefiBinary = { + x86_64-linux = "${pkgs.OVMF.fd}/FV/OVMF.fd"; + aarch64-linux = "${pkgs.OVMF.fd}/FV/QEMU_EFI.fd"; + }.${pkgs.stdenv.hostPlatform.system}; in { + uefiCdrom = makeBootTest "uefi-cdrom" { + cdrom = "${iso}/iso/${iso.isoName}"; + bios = uefiBinary; + }; + uefiUsb = makeBootTest "uefi-usb" { + usb = "${iso}/iso/${iso.isoName}"; + bios = uefiBinary; + }; + + uefiNetboot = makeNetbootTest "uefi" { + bios = uefiBinary; + # Custom ROM is needed for EFI PXE boot. I failed to understand exactly why, because QEMU should still use iPXE for EFI. + netFrontendArgs = "romfile=${pkgs.ipxe}/ipxe.efirom"; + }; +} // optionalAttrs (pkgs.stdenv.hostPlatform.system == "x86_64-linux") { biosCdrom = makeBootTest "bios-cdrom" { cdrom = "${iso}/iso/${iso.isoName}"; }; @@ -85,21 +109,5 @@ in { usb = "${iso}/iso/${iso.isoName}"; }; - uefiCdrom = makeBootTest "uefi-cdrom" { - cdrom = "${iso}/iso/${iso.isoName}"; - bios = "${pkgs.OVMF.fd}/FV/OVMF.fd"; - }; - - uefiUsb = makeBootTest "uefi-usb" { - usb = "${iso}/iso/${iso.isoName}"; - bios = "${pkgs.OVMF.fd}/FV/OVMF.fd"; - }; - biosNetboot = makeNetbootTest "bios" {}; - - uefiNetboot = makeNetbootTest "uefi" { - bios = "${pkgs.OVMF.fd}/FV/OVMF.fd"; - # Custom ROM is needed for EFI PXE boot. I failed to understand exactly why, because QEMU should still use iPXE for EFI. - netFrontendArgs = "romfile=${pkgs.ipxe}/ipxe.efirom"; - }; }