From aab2a9cd26495e79951691438f6b65fad097b478 Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 1 Mar 2023 04:45:59 +0000 Subject: [PATCH] cross compilation: gmime3: build with gpgme support (needed by `notmuch`) --- hosts/common/cross.nix | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/hosts/common/cross.nix b/hosts/common/cross.nix index aa90bc55..5c1734a5 100644 --- a/hosts/common/cross.nix +++ b/hosts/common/cross.nix @@ -427,17 +427,40 @@ in # fixes (meson) "Program 'glib-mkenums mkenums' not found or not executable" nativeBuildInputs = orig.nativeBuildInputs ++ [ next.glib ]; }); - gmime = prev.gmime.overrideAttrs (orig: { - # fixes: "checking preferred charset formats for system iconv... cannot run test program while cross compiling" - configureFlags = orig.configureFlags ++ [ "ac_cv_have_iconv_detect_h=no" ]; + + gmime = prev.gmime.overrideAttrs (upstream: { + configureFlags = upstream.configureFlags ++ [ + "ac_cv_have_iconv_detect_h=yes" # fixes: "checking preferred charset formats for system iconv... cannot run test program while cross compiling" + "--enable-cryptography=yes" # force GPGME (TODO: might not be necessary?) + ]; + postPatch = upstream.postPatch + '' + # mimick how upstream builds iconv-detect.h + # the resulting binary is for the host, but unlike configure we know how to invoke that. + "$CC" ./iconv-detect.c -o iconv-detect + ./iconv-detect + rm iconv-detect + ''; }); gmime3 = prev.gmime3.overrideAttrs (upstream: { configureFlags = upstream.configureFlags ++ [ - "ac_cv_have_iconv_detect_h=no" # fixes: "checking preferred charset formats for system iconv... cannot run test program while cross compiling" + "ac_cv_have_iconv_detect_h=yes" # fixes: "checking preferred charset formats for system iconv... cannot run test program while cross compiling" + "--enable-crypto=yes" # force GPGME (TODO: might not be necessary?) ]; + postPatch = upstream.postPatch + '' + # mimick how upstream builds iconv-detect.h + # the resulting binary is for the host, but unlike configure we know how to invoke that. + "$CC" ./iconv-detect.c -o iconv-detect + ./iconv-detect + rm iconv-detect + ''; nativeBuildInputs = upstream.nativeBuildInputs or [] ++ [ next.buildPackages.gobject-introspection ]; + # configure detects gpgme support by invoking `gpgme-config` which otherwise fails on cross-compiled builds and causes gmime3 to build without gpgme support. + # consumers of gmime3 expect gpgme support, so make sure we build it on all platforms with this. + GPGME_CONFIG = next.buildPackages.writeShellScript "gpgme-config" '' + exec ${lib.getBin next.gpgme.dev}/bin/gpgme-config $@ + ''; }); # gmime3 = prev.gmime3.overrideAttrs (orig: {