From 161355f6c3713deb29f2bfcb954ba9fc7c630217 Mon Sep 17 00:00:00 2001 From: Adam Stephens Date: Wed, 19 Jun 2024 21:34:08 -0400 Subject: [PATCH] edk2: simplify src by using postFetch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ❯ ls -ld result-new result-statusquo lrwxrwxrwx - adam 19 Jun 21:20 result-new -> /nix/store/srk9dl484fh6fr4qpzxah0cwmhhz86xd-source lrwxrwxrwx - adam 19 Jun 21:09 result-statusquo -> /nix/store/p3kl9i7xwpaczbh30riqgj1z51w1zilr-edk2-unvendored-src ❯ diff -r result-new result-statusquo diff: result-new/EmulatorPkg/Unix/Host/X11IncludeHack: No such file or directory diff: result-statusquo/EmulatorPkg/Unix/Host/X11IncludeHack: No such file or directory --- pkgs/development/compilers/edk2/default.nix | 37 +++++++++------------ 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/pkgs/development/compilers/edk2/default.nix b/pkgs/development/compilers/edk2/default.nix index cd15f29e370c..524ff18471b8 100644 --- a/pkgs/development/compilers/edk2/default.nix +++ b/pkgs/development/compilers/edk2/default.nix @@ -1,10 +1,7 @@ { stdenv -, clangStdenv , fetchFromGitHub , fetchpatch -, runCommand , libuuid -, python3 , bc , lib , buildPackages @@ -31,7 +28,7 @@ buildType = if stdenv.isDarwin then else "GCC5"; -edk2 = stdenv.mkDerivation rec { +edk2 = stdenv.mkDerivation { pname = "edk2"; version = "202402"; @@ -48,29 +45,27 @@ edk2 = stdenv.mkDerivation rec { }) ]; - srcWithVendoring = fetchFromGitHub { + src = fetchFromGitHub { owner = "tianocore"; repo = "edk2"; rev = "edk2-stable${edk2.version}"; fetchSubmodules = true; - hash = "sha256-Nurm6QNKCyV6wvbj0ELdYAL7mbZ0yg/tTwnEJ+N18ng="; + hash = "sha256-xIOaM4l08R7OqYgCIl17qeKO0xWy+3qTwyrknzQWA40="; + + # We don't want EDK2 to keep track of OpenSSL, + # they're frankly bad at it. + postFetch = '' + rm -rf $out/CryptoPkg/Library/OpensslLib/openssl + mkdir -p $out/CryptoPkg/Library/OpensslLib/openssl + tar --strip-components=1 -xf ${buildPackages.openssl.src} -C $out/CryptoPkg/Library/OpensslLib/openssl + + # Fix missing INT64_MAX include that edk2 explicitly does not provide + # via it's own . Let's pull in openssl's definition instead: + sed -i $out/CryptoPkg/Library/OpensslLib/openssl/crypto/property/property_parse.c \ + -e '1i #include "internal/numbers.h"' + ''; }; - # We don't want EDK2 to keep track of OpenSSL, - # they're frankly bad at it. - src = runCommand "edk2-unvendored-src" { } '' - cp --no-preserve=mode -r ${srcWithVendoring} $out - rm -rf $out/CryptoPkg/Library/OpensslLib/openssl - mkdir -p $out/CryptoPkg/Library/OpensslLib/openssl - tar --strip-components=1 -xf ${buildPackages.openssl.src} -C $out/CryptoPkg/Library/OpensslLib/openssl - chmod -R +w $out/ - - # Fix missing INT64_MAX include that edk2 explicitly does not provide - # via it's own . Let's pull in openssl's definition instead: - sed -i $out/CryptoPkg/Library/OpensslLib/openssl/crypto/property/property_parse.c \ - -e '1i #include "internal/numbers.h"' - ''; - nativeBuildInputs = [ pythonEnv ]; depsBuildBuild = [ buildPackages.stdenv.cc buildPackages.bash ]; depsHostHost = [ libuuid ];