Files
nix-config/packages/edk2/default.nix
mjallen18 76b6255169 edk
2026-01-09 12:10:25 -06:00

110 lines
2.4 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{ stdenv
, fetchFromGitHub
, lib
, MODEL ? "5"
, RELEASE_TYPE ? "RELEASE"
, EDK2_FLAGS ? ""
, python3
, git
, libuuid
, pkgs
, namespace
}:
let
pname = "edk2";
version = "stable202511";
edk2Src = fetchFromGitHub rec {
owner = "mjallen18";
repo = "edk2";
name = repo;
#tag = "edk2-${version}";
rev = "9765be56f1f816ef737153f5588b3294fcc69a63";
hash = "sha256-oqfJbNeOj2BVJqWE+snD6ri3lUO1aNcmPg+eJpjyr5E=";
fetchSubmodules = true;
};
edk2NonOsiSrc = fetchFromGitHub rec {
owner = "mjallen18";
repo = "edk2-non-osi";
name = repo;
rev = "09ee44f07ded544d976be8a03dec3715719f638e";
hash = "sha256-k7nUb3WaRUIr9IlXdam2WGKPOzKjLNVFLfuD5h4veMc=";
};
edk2PlatformsSrc = fetchFromGitHub rec {
owner = "mjallen18";
repo = "edk2-platforms";
name = repo;
rev = "b45583a9af9953133d606e9c142b001bd6d156c2";
hash = "sha256-Bg9ujeFIWriOSdpYlQBTzViRlyalJkIPEjQUXDaZl/o=";
};
in
stdenv.mkDerivation rec {
inherit pname version;
srcs = [
edk2Src
edk2NonOsiSrc
edk2PlatformsSrc
];
# 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
for src in $srcs; do
unpackFile "$src"
done
chmod -R u+w .
patchShebangs ./edk2
runHook postUnpack
'';
buildPhase = ''
export PYTHON_COMMAND=${python3}/bin/python
export WORKSPACE=$PWD
export PACKAGES_PATH=$WORKSPACE/edk2:$WORKSPACE/edk2-non-osi:$WORKSPACE/edk2-platforms
export EDK_TOOLS_PATH=$WORKSPACE/edk2/BaseTools
make -C ./edk2/BaseTools
export ATF_BUILD_DIR="${pkgs.${namespace}.arm-trusted-firmware}/rpi${MODEL}/${RELEASE_TYPE}"
. ./edk2/edksetup.sh BaseTools
build \
-a AARCH64 \
-t GCC \
-b ${RELEASE_TYPE} \
-p edk2-platforms/Platform/RaspberryPi/RPi${MODEL}/RPi${MODEL}.dsc \
-D TFA_BUILD_ARTIFACTS=$ATF_BUILD_DIR \
--pcd gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString=L${version} \
${EDK2_FLAGS}
'';
installPhase = ''
mkdir -p $out
cp -r /Build/RPi${MODEL}/${RELEASE_TYPE}_GCC/FV/RPI_EFI.fd $out/RPI_EFI.fd
'';
meta = with lib; {
description = "ARM Trusted Firmware-A for Raspberry Pi";
license = licenses.bsd3;
platforms = [ "aarch64-linux" ];
maintainers = with maintainers; [ kazenyuk ];
};
}