From 252dcd62f39ec9163832805dd41286c75f802530 Mon Sep 17 00:00:00 2001 From: Joachim Fasting Date: Thu, 18 May 2017 12:46:14 +0200 Subject: [PATCH] OVMF: separate output for ovmf binaries OVMF{,CODE,VARS}.fd are now available in a dedicated fd output, greatly reducing the closure in the common case where only those files are used (a few MBs versus several hundred MBs for the full OVMF). Note: it's unclear why `dontPatchELF` is now necessary for the build to pass (on my end, at any rate) but it doesn't make much sense to run this fixup anyway, Note: my reading of xen's INSTALL suggests that --with-system-ovmf should point directly to the OVMF binary. As such, the previous invocation was incorrect (it pointed to the root of the OVMF tree). In any case, I have only built xen with `--with-system-ovmf`, I have not tested it. Fixes https://github.com/NixOS/nixpkgs/issues/25854 Closes https://github.com/NixOS/nixpkgs/pull/25855 --- nixos/modules/virtualisation/libvirtd.nix | 2 +- nixos/modules/virtualisation/qemu-vm.nix | 2 +- nixos/tests/boot.nix | 4 ++-- nixos/tests/installer.nix | 2 +- pkgs/applications/virtualization/OVMF/default.nix | 9 +++++++++ pkgs/applications/virtualization/xen/4.5.nix | 2 +- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/nixos/modules/virtualisation/libvirtd.nix b/nixos/modules/virtualisation/libvirtd.nix index 58581eed74a..10a38b99f87 100644 --- a/nixos/modules/virtualisation/libvirtd.nix +++ b/nixos/modules/virtualisation/libvirtd.nix @@ -15,7 +15,7 @@ let ''; qemuConfigFile = pkgs.writeText "qemu.conf" '' ${optionalString cfg.qemuOvmf '' - nvram = ["${pkgs.OVMF}/FV/OVMF_CODE.fd:${pkgs.OVMF}/FV/OVMF_VARS.fd"] + nvram = ["${pkgs.OVMF.fd}/FV/OVMF_CODE.fd:${pkgs.OVMF.fd}/FV/OVMF_VARS.fd"] ''} ${cfg.qemuVerbatimConfig} ''; diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index c75edfcd8cf..a17e2c9ca47 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -126,7 +126,7 @@ let bootFlash=$out/bios.bin ${qemu}/bin/qemu-img create -f qcow2 $diskImage "40M" ${if cfg.useEFIBoot then '' - cp ${pkgs.OVMF-CSM}/FV/OVMF.fd $bootFlash + cp ${pkgs.OVMF-CSM.fd}/FV/OVMF.fd $bootFlash chmod 0644 $bootFlash '' else '' ''} diff --git a/nixos/tests/boot.nix b/nixos/tests/boot.nix index 3ea0df65c8b..69ab4755e44 100644 --- a/nixos/tests/boot.nix +++ b/nixos/tests/boot.nix @@ -40,12 +40,12 @@ in { uefiCdrom = makeBootTest "uefi-cdrom" '' cdrom => glob("${iso}/iso/*.iso"), - bios => '${pkgs.OVMF}/FV/OVMF.fd' + bios => '${pkgs.OVMF.fd}/FV/OVMF.fd' ''; uefiUsb = makeBootTest "uefi-usb" '' usb => glob("${iso}/iso/*.iso"), - bios => '${pkgs.OVMF}/FV/OVMF.fd' + bios => '${pkgs.OVMF.fd}/FV/OVMF.fd' ''; netboot = let diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix index 3ab3c1bac48..6dce6f407cd 100644 --- a/nixos/tests/installer.nix +++ b/nixos/tests/installer.nix @@ -63,7 +63,7 @@ let (if system == "x86_64-linux" then "-m 768 " else "-m 512 ") + (optionalString (system == "x86_64-linux") "-cpu kvm64 "); hdFlags = ''hda => "vm-state-machine/machine.qcow2", hdaInterface => "${iface}", '' - + optionalString (bootLoader == "systemd-boot") ''bios => "${pkgs.OVMF}/FV/OVMF.fd", ''; + + optionalString (bootLoader == "systemd-boot") ''bios => "${pkgs.OVMF.fd}/FV/OVMF.fd", ''; in '' $machine->start; diff --git a/pkgs/applications/virtualization/OVMF/default.nix b/pkgs/applications/virtualization/OVMF/default.nix index 608ae594a2e..4f7ea37ca18 100644 --- a/pkgs/applications/virtualization/OVMF/default.nix +++ b/pkgs/applications/virtualization/OVMF/default.nix @@ -15,6 +15,8 @@ in stdenv.mkDerivation (edk2.setup "OvmfPkg/OvmfPkg${targetArch}.dsc" { name = "OVMF-${version}"; + outputs = [ "out" "fd" ]; + # TODO: properly include openssl for secureBoot buildInputs = [nasm iasl] ++ stdenv.lib.optionals (secureBoot == true) [ openssl ]; @@ -48,6 +50,13 @@ stdenv.mkDerivation (edk2.setup "OvmfPkg/OvmfPkg${targetArch}.dsc" { build -D CSM_ENABLE -D FD_SIZE_2MB ${if secureBoot then "-DSECURE_BOOT_ENABLE=TRUE" else ""} ''; + postFixup = '' + mkdir -p $fd/FV + mv $out/FV/OVMF{,_CODE,_VARS}.fd $fd/FV + ''; + + dontPatchELF = true; + meta = { description = "Sample UEFI firmware for QEMU and KVM"; homepage = http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=OVMF; diff --git a/pkgs/applications/virtualization/xen/4.5.nix b/pkgs/applications/virtualization/xen/4.5.nix index 754f800afad..3fbdee981c4 100644 --- a/pkgs/applications/virtualization/xen/4.5.nix +++ b/pkgs/applications/virtualization/xen/4.5.nix @@ -167,7 +167,7 @@ callPackage (import ./generic.nix (rec { ++ optional (withSeabios) "--with-system-seabios=${seabios}" ++ optional (!withInternalSeabios && !withSeabios) "--disable-seabios" - ++ optional (withOVMF) "--with-system-ovmf=${OVMF}" + ++ optional (withOVMF) "--with-system-ovmf=${OVMF.fd}/FV/OVMF.fd" ++ optional (withInternalOVMF) "--enable-ovmf"; patches =