1{ stdenv, edk2, nasm, iasl, seabios, openssl, secureBoot ? false }:
2
3let
4
5 targetArch = if stdenv.isi686 then
6 "Ia32"
7 else if stdenv.isx86_64 then
8 "X64"
9 else
10 throw "Unsupported architecture";
11
12in
13
14stdenv.mkDerivation (edk2.setup "OvmfPkg/OvmfPkg${targetArch}.dsc" {
15 name = "OVMF-2014-12-10";
16
17 # TODO: properly include openssl for secureBoot
18 buildInputs = [nasm iasl] ++ stdenv.lib.optionals (secureBoot == true) [ openssl ];
19
20 unpackPhase = ''
21 for file in \
22 "${edk2.src}"/{UefiCpuPkg,MdeModulePkg,IntelFrameworkModulePkg,PcAtChipsetPkg,FatBinPkg,EdkShellBinPkg,MdePkg,ShellPkg,OptionRomPkg,IntelFrameworkPkg};
23 do
24 ln -sv "$file" .
25 done
26
27 ${if (seabios == false) then ''
28 ln -sv ${edk2.src}/OvmfPkg .
29 '' else ''
30 cp -r ${edk2.src}/OvmfPkg .
31 chmod +w OvmfPkg/Csm/Csm16
32 cp ${seabios}/Csm16.bin OvmfPkg/Csm/Csm16/Csm16.bin
33 ''}
34
35 ${if (secureBoot == true) then ''
36 ln -sv ${edk2.src}/SecurityPkg .
37 ln -sv ${edk2.src}/CryptoPkg .
38 '' else ''
39 ''}
40 '';
41
42 buildPhase = if (seabios == false) then ''
43 build ${if secureBoot then "-DSECURE_BOOT_ENABLE=TRUE" else ""}
44 '' else ''
45 build -D CSM_ENABLE -D FD_SIZE_2MB ${if secureBoot then "-DSECURE_BOOT_ENABLE=TRUE" else ""}
46 '';
47
48 meta = {
49 description = "Sample UEFI firmware for QEMU and KVM";
50 homepage = http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=OVMF;
51 license = stdenv.lib.licenses.bsd2;
52 platforms = ["x86_64-linux" "i686-linux"];
53 };
54})