From 77a189e066a839b1c8bb7cb8c125d434d15854ac Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sat, 23 Apr 2022 18:49:59 +0100 Subject: [PATCH] systemd: disable EFI stripping In Issue #169693 we found out that systemd-bootaa64.efi does not have required `#### LoaderInfo: systemd-boot 250.4 ####` marking. It is destroyed by `nixpkgs`'s `_doStrip` hook (part of `fixupOutputHooks`). It makes sense as PE32+ is a bit different from ELF where `.sdmagic` section is inserted. The change avoids stripping EFI files altogether by moving them out of default strip directories of _doStrip for the time while `fixupPhase` is running. Closes: https://github.com/NixOS/nixpkgs/issues/169693 --- pkgs/os-specific/linux/systemd/default.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix index e130abbf27ff..a32083850b57 100644 --- a/pkgs/os-specific/linux/systemd/default.nix +++ b/pkgs/os-specific/linux/systemd/default.nix @@ -666,6 +666,18 @@ stdenv.mkDerivation { rm -rf $out/share/doc ''; + # Avoid *.EFI binary stripping. At least on aarch64-linux strip + # removes too much from PE32+ files: + # https://github.com/NixOS/nixpkgs/issues/169693 + # The hack is to move EFI file out of lib/ before doStrip + # run and return it after doStrip run. + preFixup = lib.optionalString withEfi '' + mv $out/lib/systemd/boot/efi $out/dont-strip-me + ''; + postFixup = lib.optionalString withEfi '' + mv $out/dont-strip-me $out/lib/systemd/boot/efi + ''; + passthru = { # The interface version prevents NixOS from switching to an # incompatible systemd at runtime. (Switching across reboots is