From 6cf8e4f81530f96a67061aa411e2270334725ecd Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Wed, 14 Mar 2012 06:57:58 +0000 Subject: [PATCH] EDK2: Significant cleanup and modularization, and add OVMF as an example of how to use it svn path=/nixpkgs/trunk/; revision=33059 --- .../virtualization/OVMF/default.nix | 19 +++++ pkgs/development/compilers/edk2/default.nix | 73 ++++++++++++------- pkgs/top-level/all-packages.nix | 2 + 3 files changed, 68 insertions(+), 26 deletions(-) create mode 100644 pkgs/applications/virtualization/OVMF/default.nix diff --git a/pkgs/applications/virtualization/OVMF/default.nix b/pkgs/applications/virtualization/OVMF/default.nix new file mode 100644 index 00000000000..a22d9737083 --- /dev/null +++ b/pkgs/applications/virtualization/OVMF/default.nix @@ -0,0 +1,19 @@ +{ stdenv, edk2 }: + +stdenv.mkDerivation (edk2.setup "OvmfPkg/OvmfPkgX64.dsc" { + name = "OVMF-2012-03-13"; + + src = edk2.src; + + patchPhase = '' + rm -fR Conf BaseTools EdkCompatibilityPkg + ''; + + meta = { + description = "Sample UEFI firmware for QEMU and KVM"; + homepage = http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=OVMF; + license = "BSD"; + maintainers = [ stdenv.lib.maintainers.shlevy ]; + platforms = ["x86_64-linux" "i686-linux"]; + }; +}) diff --git a/pkgs/development/compilers/edk2/default.nix b/pkgs/development/compilers/edk2/default.nix index c93c7b8630f..047834bbb62 100644 --- a/pkgs/development/compilers/edk2/default.nix +++ b/pkgs/development/compilers/edk2/default.nix @@ -2,16 +2,14 @@ let - targetArch = if stdenv.isi686 then - "IA32" - else if stdenv.isx86_64 then - "X64" - else - throw "Unsupported architecture"; +targetArch = if stdenv.isi686 then + "IA32" +else if stdenv.isx86_64 then + "X64" +else + throw "Unsupported architecture"; -in - -stdenv.mkDerivation { +edk2 = stdenv.mkDerivation { name = "edk2-2012-03-13"; src = fetchsvn { @@ -24,24 +22,14 @@ stdenv.mkDerivation { buildPhase = '' make -C BaseTools - build="$(pwd)" - cd .. - mv $build $out - export EDK_TOOLS_PATH="$out"/BaseTools - cd $out - . edksetup.sh BaseTools - sed -e 's|Nt32Pkg/Nt32Pkg.dsc|MdeModulePkg/MdeModulePkg.dsc|' -e \ - 's|MYTOOLS|GCC46|' -e 's|IA32|${targetArch}|' -e 's|DEBUG|RELEASE|'\ - < $out/Conf/target.txt > target.txt.tmp - mv target.txt.tmp $out/Conf/target.txt - sed -e 's|DEFINE GCC46_IA32_PREFIX = /usr/bin/|DEFINE GCC46_IA32_PREFIX = ""|' \ - -e 's|DEFINE GCC46_X64_PREFIX = /usr/bin/|DEFINE GCC46_X64_PREFIX = ""|' \ - -e 's|DEFINE UNIX_IASL_BIN = /usr/bin/iasl|DEFINE UNIX_IASL_BIN = ${iasl}/bin/iasl|' < $out/Conf/tools_def.txt > tools_def.txt.tmp - mv tools_def.txt.tmp $out/Conf/tools_def.txt - build ''; - installPhase = "true"; + installPhase = '' + mkdir -vp $out + mv -v BaseTools $out + mv -v EdkCompatibilityPkg $out + mv -v edksetup.sh $out + ''; meta = { description = "Intel EFI development kit"; @@ -50,4 +38,37 @@ stdenv.mkDerivation { maintainers = [ stdenv.lib.maintainers.shlevy ]; platforms = ["x86_64-linux" "i686-linux"]; }; -} + + passthru = { + setup = projectDscPath: attrs: { + buildInputs = [ pythonFull ] ++ + stdenv.lib.optionals (attrs ? buildInputs) attrs.buildInputs; + + configurePhase = '' + mkdir -v Conf + sed -e 's|Nt32Pkg/Nt32Pkg.dsc|${projectDscPath}|' -e \ + 's|MYTOOLS|GCC46|' -e 's|IA32|${targetArch}|' -e 's|DEBUG|RELEASE|'\ + < ${edk2}/BaseTools/Conf/target.template > Conf/target.txt + sed -e 's|DEFINE GCC46_IA32_PREFIX = /usr/bin/|DEFINE GCC46_IA32_PREFIX = ""|' \ + -e 's|DEFINE GCC46_X64_PREFIX = /usr/bin/|DEFINE GCC46_X64_PREFIX = ""|' \ + -e 's|DEFINE UNIX_IASL_BIN = /usr/bin/iasl|DEFINE UNIX_IASL_BIN = ${iasl}/bin/iasl|' \ + < ${edk2}/BaseTools/Conf/tools_def.template > Conf/tools_def.txt + export WORKSPACE="$PWD" + export EFI_SOURCE="$PWD/EdkCompatibilityPkg" + ln -sv ${edk2}/BaseTools BaseTools + ln -sv ${edk2}/EdkCompatibilityPkg EdkCompatibilityPkg + . ${edk2}/edksetup.sh BaseTools + ''; + + buildPhase = " + build + "; + + installPhase = "mv -v Build $out"; + } // (removeAttrs attrs [ "buildInputs" ] ); + }; +}; + +in + +edk2 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 16cebd04435..a54387b95f5 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5192,6 +5192,8 @@ let oidentd = callPackage ../servers/identd/oidentd { }; openfire = callPackage ../servers/xmpp/openfire { }; + + OVMF = callPackage ../applications/virtualization/OVMF { }; postgresql = postgresql83;