![Markus Partheymüller](/assets/img/avatar_default.png)
In order to use OVMF firmware with e.g. qemu on macOS, these packages needed to be made macOS ready. This meant choosing the clang build in this case, because it is the only one working on macOS. Unfortunately, just using clang on all platforms doesn't work because there are hardcoded assumptions in the edk2 build system.
104 lines
2.3 KiB
Nix
104 lines
2.3 KiB
Nix
{
|
|
stdenv,
|
|
clangStdenv,
|
|
fetchgit,
|
|
fetchpatch,
|
|
libuuid,
|
|
python3,
|
|
iasl,
|
|
bc,
|
|
clang_9,
|
|
llvmPackages_9,
|
|
overrideCC,
|
|
lib,
|
|
}:
|
|
|
|
let
|
|
pythonEnv = python3.withPackages (ps: [ps.tkinter]);
|
|
|
|
targetArch = if stdenv.isi686 then
|
|
"IA32"
|
|
else if stdenv.isx86_64 then
|
|
"X64"
|
|
else if stdenv.isAarch64 then
|
|
"AARCH64"
|
|
else
|
|
throw "Unsupported architecture";
|
|
|
|
buildStdenv = if stdenv.isDarwin then
|
|
overrideCC clangStdenv [ clang_9 llvmPackages_9.llvm llvmPackages_9.lld ]
|
|
else
|
|
stdenv;
|
|
|
|
edk2 = buildStdenv.mkDerivation {
|
|
pname = "edk2";
|
|
version = "201911";
|
|
|
|
# submodules
|
|
src = fetchgit {
|
|
url = "https://github.com/tianocore/edk2";
|
|
rev = "edk2-stable${edk2.version}";
|
|
sha256 = "1rmvb4w043v25cppsqxqrpzqqcay3yrzsrhhzm2q9bncrj56vm8q";
|
|
};
|
|
|
|
buildInputs = [ libuuid pythonEnv ];
|
|
|
|
makeFlags = [ "-C BaseTools" ]
|
|
++ lib.optional (stdenv.isDarwin) [ "BUILD_CC=clang BUILD_CXX=clang++ BUILD_AS=clang" ];
|
|
|
|
NIX_CFLAGS_COMPILE = "-Wno-return-type" + lib.optionalString (!stdenv.isDarwin) " -Wno-error=stringop-truncation";
|
|
|
|
hardeningDisable = [ "format" "fortify" ];
|
|
|
|
installPhase = ''
|
|
mkdir -vp $out
|
|
mv -v BaseTools $out
|
|
mv -v edksetup.sh $out
|
|
'';
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
meta = with lib; {
|
|
description = "Intel EFI development kit";
|
|
homepage = https://sourceforge.net/projects/edk2/;
|
|
license = licenses.bsd2;
|
|
platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" ];
|
|
};
|
|
|
|
passthru = {
|
|
mkDerivation = projectDscPath: buildType: attrs: buildStdenv.mkDerivation ({
|
|
inherit (edk2) src;
|
|
|
|
buildInputs = [ bc pythonEnv ] ++ attrs.buildInputs or [];
|
|
|
|
prePatch = ''
|
|
rm -rf BaseTools
|
|
ln -sv ${edk2}/BaseTools BaseTools
|
|
'';
|
|
|
|
configurePhase = ''
|
|
runHook preConfigure
|
|
export WORKSPACE="$PWD"
|
|
. ${edk2}/edksetup.sh BaseTools
|
|
runHook postConfigure
|
|
'';
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
build -a ${targetArch} -b RELEASE -t ${buildType} -p ${projectDscPath} -n $NIX_BUILD_CORES $buildFlags
|
|
runHook postBuild
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
mv -v Build/*/* $out
|
|
runHook postInstall
|
|
'';
|
|
} // removeAttrs attrs [ "buildInputs" ]);
|
|
};
|
|
};
|
|
|
|
in
|
|
|
|
edk2
|