Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 20.09 108 lines 2.4 kB view raw
1{ 2 stdenv, 3 clangStdenv, 4 fetchgit, 5 fetchpatch, 6 libuuid, 7 python3, 8 iasl, 9 bc, 10 clang_9, 11 llvmPackages_9, 12 overrideCC, 13 lib, 14}: 15 16let 17 pythonEnv = python3.withPackages (ps: [ps.tkinter]); 18 19targetArch = if stdenv.isi686 then 20 "IA32" 21else if stdenv.isx86_64 then 22 "X64" 23else if stdenv.isAarch64 then 24 "AARCH64" 25else 26 throw "Unsupported architecture"; 27 28buildStdenv = if stdenv.isDarwin then 29 overrideCC clangStdenv [ clang_9 llvmPackages_9.llvm llvmPackages_9.lld ] 30else 31 stdenv; 32 33buildType = if stdenv.isDarwin then 34 "CLANGPDB" 35 else 36 "GCC5"; 37 38edk2 = buildStdenv.mkDerivation { 39 pname = "edk2"; 40 version = "201911"; 41 42 # submodules 43 src = fetchgit { 44 url = "https://github.com/tianocore/edk2"; 45 rev = "edk2-stable${edk2.version}"; 46 sha256 = "1rmvb4w043v25cppsqxqrpzqqcay3yrzsrhhzm2q9bncrj56vm8q"; 47 }; 48 49 buildInputs = [ libuuid pythonEnv ]; 50 51 makeFlags = [ "-C BaseTools" ] 52 ++ lib.optional (stdenv.cc.isClang) [ "BUILD_CC=clang BUILD_CXX=clang++ BUILD_AS=clang" ]; 53 54 NIX_CFLAGS_COMPILE = "-Wno-return-type" + lib.optionalString (stdenv.cc.isGNU) " -Wno-error=stringop-truncation"; 55 56 hardeningDisable = [ "format" "fortify" ]; 57 58 installPhase = '' 59 mkdir -vp $out 60 mv -v BaseTools $out 61 mv -v edksetup.sh $out 62 ''; 63 64 enableParallelBuilding = true; 65 66 meta = with lib; { 67 description = "Intel EFI development kit"; 68 homepage = "https://sourceforge.net/projects/edk2/"; 69 license = licenses.bsd2; 70 platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" ]; 71 }; 72 73 passthru = { 74 mkDerivation = projectDscPath: attrs: buildStdenv.mkDerivation ({ 75 inherit (edk2) src; 76 77 buildInputs = [ bc pythonEnv ] ++ attrs.buildInputs or []; 78 79 prePatch = '' 80 rm -rf BaseTools 81 ln -sv ${edk2}/BaseTools BaseTools 82 ''; 83 84 configurePhase = '' 85 runHook preConfigure 86 export WORKSPACE="$PWD" 87 . ${edk2}/edksetup.sh BaseTools 88 runHook postConfigure 89 ''; 90 91 buildPhase = '' 92 runHook preBuild 93 build -a ${targetArch} -b RELEASE -t ${buildType} -p ${projectDscPath} -n $NIX_BUILD_CORES $buildFlags 94 runHook postBuild 95 ''; 96 97 installPhase = '' 98 runHook preInstall 99 mv -v Build/*/* $out 100 runHook postInstall 101 ''; 102 } // removeAttrs attrs [ "buildInputs" ]); 103 }; 104}; 105 106in 107 108edk2