2020-05-15 21:57:56 +00:00
|
|
|
{
|
|
|
|
stdenv,
|
|
|
|
clangStdenv,
|
|
|
|
fetchgit,
|
|
|
|
fetchpatch,
|
|
|
|
libuuid,
|
|
|
|
python3,
|
|
|
|
iasl,
|
|
|
|
bc,
|
|
|
|
clang_9,
|
|
|
|
llvmPackages_9,
|
|
|
|
overrideCC,
|
|
|
|
lib,
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
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";
|
|
|
|
|
2020-05-15 21:57:56 +00:00
|
|
|
buildStdenv = if stdenv.isDarwin then
|
|
|
|
overrideCC clangStdenv [ clang_9 llvmPackages_9.llvm llvmPackages_9.lld ]
|
|
|
|
else
|
|
|
|
stdenv;
|
|
|
|
|
|
|
|
buildType = if stdenv.isDarwin then
|
|
|
|
"CLANGPDB"
|
|
|
|
else
|
|
|
|
"GCC5";
|
|
|
|
|
|
|
|
edk2 = buildStdenv.mkDerivation {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "edk2";
|
2020-12-03 08:41:04 +00:00
|
|
|
version = "202011";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# submodules
|
|
|
|
src = fetchgit {
|
|
|
|
url = "https://github.com/tianocore/edk2";
|
|
|
|
rev = "edk2-stable${edk2.version}";
|
2020-12-03 08:41:04 +00:00
|
|
|
sha256 = "1fvlz1z075jr6smq9qa0asy6fxga1gljcfd0764ypzy1mw963c9s";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [ libuuid pythonEnv ];
|
|
|
|
|
2020-05-15 21:57:56 +00:00
|
|
|
makeFlags = [ "-C BaseTools" ]
|
|
|
|
++ lib.optional (stdenv.cc.isClang) [ "BUILD_CC=clang BUILD_CXX=clang++ BUILD_AS=clang" ];
|
|
|
|
|
|
|
|
NIX_CFLAGS_COMPILE = "-Wno-return-type" + lib.optionalString (stdenv.cc.isGNU) " -Wno-error=stringop-truncation";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
hardeningDisable = [ "format" "fortify" ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -vp $out
|
|
|
|
mv -v BaseTools $out
|
|
|
|
mv -v edksetup.sh $out
|
|
|
|
'';
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2020-05-15 21:57:56 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Intel EFI development kit";
|
|
|
|
homepage = "https://sourceforge.net/projects/edk2/";
|
|
|
|
license = licenses.bsd2;
|
2020-05-15 21:57:56 +00:00
|
|
|
platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
passthru = {
|
2020-05-15 21:57:56 +00:00
|
|
|
mkDerivation = projectDscPath: attrs: buildStdenv.mkDerivation ({
|
2020-04-24 23:36:52 +00:00
|
|
|
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
|
2020-05-15 21:57:56 +00:00
|
|
|
build -a ${targetArch} -b RELEASE -t ${buildType} -p ${projectDscPath} -n $NIX_BUILD_CORES $buildFlags
|
2020-04-24 23:36:52 +00:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mv -v Build/*/* $out
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
} // removeAttrs attrs [ "buildInputs" ]);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
edk2
|