mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-09-01 05:04:40 +00:00
91 lines
2.2 KiB
Nix
91 lines
2.2 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
gnu-efi,
|
|
openssl,
|
|
sbsigntool,
|
|
perl,
|
|
perlPackages,
|
|
help2man,
|
|
fetchzip,
|
|
pkgsCross,
|
|
efitools,
|
|
buildPackages,
|
|
}:
|
|
let
|
|
isCross = !(stdenv.buildPlatform.canExecute stdenv.hostPlatform);
|
|
in
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
pname = "efitools";
|
|
version = "1.9.2";
|
|
|
|
buildInputs = [
|
|
gnu-efi
|
|
openssl
|
|
];
|
|
|
|
nativeBuildInputs = [
|
|
perl
|
|
perlPackages.FileSlurp
|
|
help2man
|
|
openssl
|
|
sbsigntool
|
|
]
|
|
++ lib.optionals isCross [
|
|
efitools
|
|
];
|
|
|
|
src = fetchzip {
|
|
url = "https://git.kernel.org/pub/scm/linux/kernel/git/jejb/efitools.git/snapshot/efitools-v${finalAttrs.version}.tar.gz";
|
|
sha256 = "0jabgl2pxvfl780yvghq131ylpf82k7banjz0ksjhlm66ik8gb1i";
|
|
};
|
|
|
|
patches = [
|
|
# https://github.com/ncroxon/gnu-efi/issues/7#issuecomment-2122741592
|
|
./aarch64.patch
|
|
|
|
# Fix build with gcc15
|
|
./remove-redundant-bool.patch
|
|
|
|
# https://bugs.debian.org/1122408
|
|
./objcopy-output-target.patch
|
|
]
|
|
++ lib.optionals isCross [
|
|
# Use builder's efitools to create sig lists for host
|
|
./cross.patch
|
|
];
|
|
|
|
postPatch = ''
|
|
sed -i -e 's#/usr/include/efi#${gnu-efi}/include/efi/#g' Make.rules
|
|
sed -i -e 's#/usr/lib64/gnuefi#${gnu-efi}/lib/#g' Make.rules
|
|
sed -i -e 's#$(DESTDIR)/usr#$(out)#g' Make.rules
|
|
sed -i '$asign-efi-sig-list.o flash-var.o: CFLAGS += -D_GNU_SOURCE' Makefile
|
|
substituteInPlace lib/console.c --replace "EFI_WARN_UNKOWN_GLYPH" "EFI_WARN_UNKNOWN_GLYPH"
|
|
# Fix cross-compilation: use $(AR) and $(NM) variables instead of hardcoded commands
|
|
substituteInPlace Make.rules --replace-fail 'ar rcv' '$(AR) rcv'
|
|
substituteInPlace Make.rules --replace-fail 'nm -D' '$(NM) -D'
|
|
patchShebangs .
|
|
'';
|
|
|
|
makeFlags = [
|
|
"ARCH=${stdenv.hostPlatform.parsed.cpu.name}"
|
|
"AR=${stdenv.cc.targetPrefix}ar"
|
|
"NM=${stdenv.cc.targetPrefix}nm"
|
|
"OBJCOPY=${stdenv.cc.targetPrefix}objcopy"
|
|
]
|
|
++ lib.optionals isCross [
|
|
"MANPAGES="
|
|
];
|
|
|
|
passthru.tests = {
|
|
cross-aarch64 = pkgsCross.aarch64-multiplatform.efitools;
|
|
};
|
|
|
|
meta = {
|
|
description = "Tools for manipulating UEFI secure boot platforms";
|
|
homepage = "https://git.kernel.org/pub/scm/linux/kernel/git/jejb/efitools.git";
|
|
license = lib.licenses.gpl2Only;
|
|
platforms = lib.platforms.linux;
|
|
};
|
|
})
|