about summary refs log tree commit diff
path: root/pkgs/development/compilers/edk2/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers/edk2/default.nix')
-rw-r--r--pkgs/development/compilers/edk2/default.nix83
1 files changed, 35 insertions, 48 deletions
diff --git a/pkgs/development/compilers/edk2/default.nix b/pkgs/development/compilers/edk2/default.nix
index 809fc6a4cf1a..2a90902df1e7 100644
--- a/pkgs/development/compilers/edk2/default.nix
+++ b/pkgs/development/compilers/edk2/default.nix
@@ -1,7 +1,7 @@
-{ stdenv, fetchFromGitHub, fetchpatch, libuuid, python2, iasl }:
+{ stdenv, fetchgit, fetchpatch, libuuid, python3, iasl, bc }:
 
 let
-  pythonEnv = python2.withPackages(ps: [ps.tkinter]);
+  pythonEnv = python3.withPackages (ps: [ps.tkinter]);
 
 targetArch = if stdenv.isi686 then
   "IA32"
@@ -13,80 +13,67 @@ else
   throw "Unsupported architecture";
 
 edk2 = stdenv.mkDerivation {
-  name = "edk2-2017-12-05";
-
-  src = fetchFromGitHub {
-    owner = "tianocore";
-    repo = "edk2";
-    rev = "f71a70e7a4c93a6143d7bad8ab0220a947679697";
-    sha256 = "0k48xfwxcgcim1bhkggc19hilvsxsf5axvvcpmld0ng1fcfg0cr6";
+  pname = "edk2";
+  version = "201905";
+
+  # submodules
+  src = fetchgit {
+    url = "https://github.com/tianocore/edk2";
+    rev = "edk2-stable${edk2.version}";
+    sha256 = "0fk40h4nj4qg8shg0yd1zj4iyspslms5fx95ysi04akv90k5sqkn";
   };
 
-  patches = [
-    (fetchpatch {
-      name = "short-circuit-the-transfer-of-an-empty-S3_CONTEXT.patch";
-      url = "https://github.com/tianocore/edk2/commit/9e2a8e928995c3b1bb664b73fd59785055c6b5f6.diff";
-      sha256 = "0x24npijhgpjpsn3n74wayf8qcbaj97vi4z2iyf4almavqq8qaz4";
-    })
-  ];
-
   buildInputs = [ libuuid pythonEnv ];
 
-  makeFlags = "-C BaseTools";
+  makeFlags = [ "-C BaseTools" ];
 
   hardeningDisable = [ "format" "fortify" ];
 
   installPhase = ''
     mkdir -vp $out
     mv -v BaseTools $out
-    mv -v EdkCompatibilityPkg $out
     mv -v edksetup.sh $out
   '';
 
   enableParallelBuilding = true;
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "Intel EFI development kit";
     homepage = https://sourceforge.net/projects/edk2/;
-    license = stdenv.lib.licenses.bsd2;
-    branch = "UDK2017";
-    platforms = ["x86_64-linux" "i686-linux" "aarch64-linux"];
+    license = licenses.bsd2;
+    platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
   };
 
   passthru = {
-    setup = projectDscPath: attrs: {
-      buildInputs = [ pythonEnv ] ++
-        stdenv.lib.optionals (attrs ? buildInputs) attrs.buildInputs;
+    mkDerivation = projectDscPath: attrs: stdenv.mkDerivation ({
+      inherit (edk2) src;
 
-      configurePhase = ''
-        mkdir -v Conf
+      buildInputs = [ bc pythonEnv ] ++ attrs.buildInputs or [];
 
-        cp ${edk2}/BaseTools/Conf/target.template Conf/target.txt
-        sed -i Conf/target.txt \
-          -e 's|Nt32Pkg/Nt32Pkg.dsc|${projectDscPath}|' \
-          -e 's|MYTOOLS|GCC49|' \
-          -e 's|IA32|${targetArch}|' \
-          -e 's|DEBUG|RELEASE|'\
-
-        cp ${edk2}/BaseTools/Conf/tools_def.template Conf/tools_def.txt
-        sed -i Conf/tools_def.txt \
-          -e 's|DEFINE GCC48_IA32_PREFIX       = /usr/bin/|DEFINE GCC48_IA32_PREFIX       = ""|' \
-          -e 's|DEFINE GCC48_X64_PREFIX        = /usr/bin/|DEFINE GCC48_X64_PREFIX        = ""|' \
-          -e 's|DEFINE UNIX_IASL_BIN           = /usr/bin/iasl|DEFINE UNIX_IASL_BIN           = ${iasl}/bin/iasl|'
+      prePatch = ''
+        rm -rf BaseTools
+        ln -sv ${edk2}/BaseTools BaseTools
+      '';
 
+      configurePhase = ''
+        runHook preConfigure
         export WORKSPACE="$PWD"
-        export EFI_SOURCE="$PWD/EdkCompatibilityPkg"
-        ln -sv ${edk2}/BaseTools BaseTools
-        ln -sv ${edk2}/EdkCompatibilityPkg EdkCompatibilityPkg
         . ${edk2}/edksetup.sh BaseTools
+        runHook postConfigure
       '';
 
-      buildPhase = "
-        build
-      ";
+      buildPhase = ''
+        runHook preBuild
+        build -a ${targetArch} -b RELEASE -t GCC5 -p ${projectDscPath} -n $NIX_BUILD_CORES $buildFlags
+        runHook postBuild
+      '';
 
-      installPhase = "mv -v Build/*/* $out";
-    } // (removeAttrs attrs [ "buildInputs" ] );
+      installPhase = ''
+        runHook preInstall
+        mv -v Build/*/* $out
+        runHook postInstall
+      '';
+    } // removeAttrs attrs [ "buildInputs" ]);
   };
 };