2020-04-17 15:15:57 +02:00
|
|
|
{
|
2020-04-20 13:19:38 +02:00
|
|
|
stdenv,
|
|
|
|
clangStdenv,
|
|
|
|
fetchgit,
|
|
|
|
fetchpatch,
|
|
|
|
libuuid,
|
|
|
|
python3,
|
|
|
|
iasl,
|
|
|
|
bc,
|
|
|
|
clang_9,
|
|
|
|
llvmPackages_9,
|
|
|
|
overrideCC,
|
|
|
|
lib,
|
2020-04-17 15:15:57 +02:00
|
|
|
}:
|
2012-03-14 05:18:52 +01:00
|
|
|
|
|
|
|
let
|
2019-07-15 16:35:30 +02:00
|
|
|
pythonEnv = python3.withPackages (ps: [ps.tkinter]);
|
2012-03-14 05:18:52 +01:00
|
|
|
|
2012-03-14 07:57:58 +01:00
|
|
|
targetArch = if stdenv.isi686 then
|
|
|
|
"IA32"
|
|
|
|
else if stdenv.isx86_64 then
|
|
|
|
"X64"
|
2018-03-14 16:37:49 +01:00
|
|
|
else if stdenv.isAarch64 then
|
|
|
|
"AARCH64"
|
2012-03-14 07:57:58 +01:00
|
|
|
else
|
|
|
|
throw "Unsupported architecture";
|
2012-03-14 05:18:52 +01:00
|
|
|
|
2020-04-17 15:15:57 +02:00
|
|
|
buildStdenv = if stdenv.isDarwin then
|
|
|
|
overrideCC clangStdenv [ clang_9 llvmPackages_9.llvm llvmPackages_9.lld ]
|
|
|
|
else
|
|
|
|
stdenv;
|
|
|
|
|
2020-04-20 13:30:35 +02:00
|
|
|
buildType = if stdenv.isDarwin then
|
|
|
|
"CLANGPDB"
|
|
|
|
else
|
|
|
|
"GCC5";
|
|
|
|
|
2020-04-17 15:15:57 +02:00
|
|
|
edk2 = buildStdenv.mkDerivation {
|
2019-07-15 16:35:30 +02:00
|
|
|
pname = "edk2";
|
2020-01-29 17:32:01 +01:00
|
|
|
version = "201911";
|
2019-07-15 16:35:30 +02:00
|
|
|
|
|
|
|
# submodules
|
|
|
|
src = fetchgit {
|
|
|
|
url = "https://github.com/tianocore/edk2";
|
|
|
|
rev = "edk2-stable${edk2.version}";
|
2020-01-29 17:32:01 +01:00
|
|
|
sha256 = "1rmvb4w043v25cppsqxqrpzqqcay3yrzsrhhzm2q9bncrj56vm8q";
|
2012-03-14 05:18:52 +01:00
|
|
|
};
|
|
|
|
|
2017-12-16 04:07:05 +01:00
|
|
|
buildInputs = [ libuuid pythonEnv ];
|
2012-03-14 05:18:52 +01:00
|
|
|
|
2020-04-17 15:15:57 +02:00
|
|
|
makeFlags = [ "-C BaseTools" ]
|
2020-04-20 13:30:35 +02:00
|
|
|
++ lib.optional (stdenv.cc.isClang) [ "BUILD_CC=clang BUILD_CXX=clang++ BUILD_AS=clang" ];
|
2020-04-17 15:15:57 +02:00
|
|
|
|
2020-04-20 13:30:35 +02:00
|
|
|
NIX_CFLAGS_COMPILE = "-Wno-return-type" + lib.optionalString (stdenv.cc.isGNU) " -Wno-error=stringop-truncation";
|
2016-02-09 00:07:09 +01:00
|
|
|
|
2016-02-26 18:38:15 +01:00
|
|
|
hardeningDisable = [ "format" "fortify" ];
|
2012-03-14 05:18:52 +01:00
|
|
|
|
2012-03-14 07:57:58 +01:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -vp $out
|
|
|
|
mv -v BaseTools $out
|
|
|
|
mv -v edksetup.sh $out
|
|
|
|
'';
|
2012-03-14 05:18:52 +01:00
|
|
|
|
2017-12-16 04:07:05 +01:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2020-04-17 15:15:57 +02:00
|
|
|
meta = with lib; {
|
2012-03-14 05:18:52 +01:00
|
|
|
description = "Intel EFI development kit";
|
2020-05-04 16:00:37 +02:00
|
|
|
homepage = "https://sourceforge.net/projects/edk2/";
|
2019-07-15 16:35:30 +02:00
|
|
|
license = licenses.bsd2;
|
2020-04-17 15:15:57 +02:00
|
|
|
platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" ];
|
2012-03-14 05:18:52 +01:00
|
|
|
};
|
2012-03-14 07:57:58 +01:00
|
|
|
|
|
|
|
passthru = {
|
2020-04-20 13:30:35 +02:00
|
|
|
mkDerivation = projectDscPath: attrs: buildStdenv.mkDerivation ({
|
2019-07-15 16:35:30 +02:00
|
|
|
inherit (edk2) src;
|
2012-03-14 07:57:58 +01:00
|
|
|
|
2019-07-15 16:35:30 +02:00
|
|
|
buildInputs = [ bc pythonEnv ] ++ attrs.buildInputs or [];
|
2018-03-14 14:47:09 +01:00
|
|
|
|
2019-07-15 16:35:30 +02:00
|
|
|
prePatch = ''
|
|
|
|
rm -rf BaseTools
|
|
|
|
ln -sv ${edk2}/BaseTools BaseTools
|
|
|
|
'';
|
2018-03-14 14:47:09 +01:00
|
|
|
|
2019-07-15 16:35:30 +02:00
|
|
|
configurePhase = ''
|
|
|
|
runHook preConfigure
|
2012-03-14 07:57:58 +01:00
|
|
|
export WORKSPACE="$PWD"
|
|
|
|
. ${edk2}/edksetup.sh BaseTools
|
2019-07-15 16:35:30 +02:00
|
|
|
runHook postConfigure
|
2012-03-14 07:57:58 +01:00
|
|
|
'';
|
|
|
|
|
2019-07-15 16:35:30 +02:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2020-04-17 15:15:57 +02:00
|
|
|
build -a ${targetArch} -b RELEASE -t ${buildType} -p ${projectDscPath} -n $NIX_BUILD_CORES $buildFlags
|
2019-07-15 16:35:30 +02:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
2012-03-14 07:57:58 +01:00
|
|
|
|
2019-07-15 16:35:30 +02:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mv -v Build/*/* $out
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
} // removeAttrs attrs [ "buildInputs" ]);
|
2012-03-14 07:57:58 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
edk2
|