This commit is contained in:
mjallen18
2026-01-12 20:11:44 -06:00
parent a59d5ce3b1
commit 2a17112d50
2 changed files with 169 additions and 14 deletions

View File

@@ -0,0 +1,108 @@
{ stdenv
, fetchFromGitHub
, lib
, applyPatches
, fetchpatch
, MODEL ? "5"
, RELEASE_TYPE ? "RELEASE"
, EDK2_FLAGS ? ""
, python3
, git
, libuuid
, pkgs
, namespace
}:
let
pythonEnv = python3.withPackages (ps: [ ps.tkinter ]);
pname = "edk2-basetools";
version = "stable202511";
in
stdenv.mkDerivation rec {
inherit pname version;
edk2Src = fetchFromGitHub rec {
owner = "mjallen18";
repo = "edk2";
name = repo;
#tag = "edk2-${version}";
rev = "9765be56f1f816ef737153f5588b3294fcc69a63";
hash = "sha256-oqfJbNeOj2BVJqWE+snD6ri3lUO1aNcmPg+eJpjyr5E=";
fetchSubmodules = true;
};
env = {
NIX_CFLAGS_COMPILE =
"-Wno-return-type"
+ lib.optionalString (stdenv.cc.isGNU) " -Wno-error=stringop-truncation"
+ lib.optionalString (stdenv.hostPlatform.isDarwin) " -Wno-error=macro-redefined";
PYTHON_COMMAND = lib.getExe pythonEnv;
# trick taken from https://src.fedoraproject.org/rpms/edk2/blob/08f2354cd280b4ce5a7888aa85cf520e042955c3/f/edk2.spec#_319
${"GCC5_AARCH64_PREFIX"} = stdenv.cc.targetPrefix;
};
# Add required host tools if needed:
nativeBuildInputs = [
python3
git
libuuid
];
# Dont force a single root; we keep both dirs side by side
sourceRoot = ".";
unpackPhase = ''
runHook preUnpack
unpackFile "$edk2Src"
chmod -R u+w .
patchShebangs ./edk2
runHook postUnpack
'';
# FIXME: unvendor OpenSSL again once upstream updates
# to a compatible version.
# Upstream PR: https://github.com/tianocore/edk2/pull/10946
postPatch = ''
# enable compilation using Clang
# https://bugzilla.tianocore.org/show_bug.cgi?id=4620
ls -alh
substituteInPlace edk2/BaseTools/Conf/tools_def.template --replace-fail \
'DEFINE CLANGPDB_WARNING_OVERRIDES = ' \
'DEFINE CLANGPDB_WARNING_OVERRIDES = -Wno-unneeded-internal-declaration '
'';
buildPhase = ''
export PYTHON_COMMAND=${python3}/bin/python
export WORKSPACE=$PWD
make -C ./edk2/BaseTools
'';
installPhase = ''
runHook preInstall
mkdir -vp $out
mv -v ./edk2/BaseTools $out
mv -v ./edk2/edksetup.sh $out
# patchShebangs fails to see these when cross compiling
for i in $out/BaseTools/BinWrappers/PosixLike/*; do
chmod +x "$i"
patchShebangs --build "$i"
done
runHook postInstall
'';
enableParallelBuilding = true;
meta = with lib; {
description = "ARM Trusted Firmware-A for Raspberry Pi";
license = licenses.bsd3;
platforms = [ "aarch64-linux" ];
maintainers = with maintainers; [ kazenyuk ];
};
}