From a85b87ed88555aa760be5e116966303608aee78f Mon Sep 17 00:00:00 2001 From: SCOTT-HAMILTON Date: Sun, 29 Aug 2021 00:38:11 +0200 Subject: [PATCH 1/3] mesonShlibsToStaticHook: init --- .../setup-hooks/meson-shlibs-to-static.sh | 21 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 7 +++++++ 2 files changed, 28 insertions(+) create mode 100644 pkgs/build-support/setup-hooks/meson-shlibs-to-static.sh diff --git a/pkgs/build-support/setup-hooks/meson-shlibs-to-static.sh b/pkgs/build-support/setup-hooks/meson-shlibs-to-static.sh new file mode 100644 index 0000000000000..6b357a6dc0256 --- /dev/null +++ b/pkgs/build-support/setup-hooks/meson-shlibs-to-static.sh @@ -0,0 +1,21 @@ +preConfigurePhases+=" mesonShlibsToStaticPhase" + +mesonShlibsToStaticPhase() { + runHook preMesonShlibsToStatic + replaceMesonFunction() { + foundFiles=$(find . -name "meson.build" -exec grep -El " * *$1 *\(" {} \;) + for mesonFile in $foundFiles + do + echo "$mesonFile"; + cp "$mesonFile" "$mesonFile.tmp_file_mesonShlibsToStaticPhase" + sed -i -E "s=( * *)$1( *)\(=\1$2(\2=g" "$mesonFile"; + echo -n "[meson-shlibs-to-static] applied patch : " + diff -u "$mesonFile.tmp_file_mesonShlibsToStaticPhase" "$mesonFile" || echo "" + rm -f "$mesonFile.tmp_file_mesonShlibsToStaticPhase" + done + } + replaceMesonFunction "shared_library" "static_library" + replaceMesonFunction "shared_module" "static_library" + + runHook postMesonShlibsToStatic +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 24b91291488a4..d7cb3e3f46ece 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -132,6 +132,13 @@ with pkgs; ../build-support/setup-hooks/autoreconf.sh ) { }; + mesonShlibsToStaticHook = callPackage ( + { makeSetupHook }: + makeSetupHook + { deps = []; } + ../build-support/setup-hooks/meson-shlibs-to-static.sh + ) { }; + autoreconfHook264 = autoreconfHook.override { autoconf = autoconf264; automake = automake111x; From 9b1443b3e6605ecb3e8634764e71e40afcab4af8 Mon Sep 17 00:00:00 2001 From: SCOTT-HAMILTON Date: Sun, 29 Aug 2021 00:36:29 +0200 Subject: [PATCH 2/3] p11-kit: use meson instead of autotool --- .../development/libraries/p11-kit/default.nix | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/pkgs/development/libraries/p11-kit/default.nix b/pkgs/development/libraries/p11-kit/default.nix index 4ddc01ee6b2bf..fb762f44a75c5 100644 --- a/pkgs/development/libraries/p11-kit/default.nix +++ b/pkgs/development/libraries/p11-kit/default.nix @@ -1,5 +1,5 @@ -{ lib, stdenv, fetchFromGitHub, autoreconfHook, pkg-config, which -, gettext, libffi, libiconv, libtasn1 +{ lib, stdenv, fetchFromGitHub, meson, ninja, pkg-config, which +, gettext, libffi, libiconv, libtasn1, bash-completion }: stdenv.mkDerivation rec { @@ -21,17 +21,15 @@ stdenv.mkDerivation rec { # at the same time, libtasn1 in buildInputs provides the libasn1 library # to link against for the target platform. # hence, libtasn1 is required in both native and build inputs. - nativeBuildInputs = [ autoreconfHook pkg-config which libtasn1 ]; + nativeBuildInputs = [ meson ninja pkg-config which libtasn1 ]; buildInputs = [ gettext libffi libiconv libtasn1 ]; + propagatedBuildInputs = [ bash-completion ]; - autoreconfPhase = '' - NOCONFIGURE=1 ./autogen.sh - ''; - - configureFlags = [ - "--sysconfdir=/etc" - "--localstatedir=/var" - "--with-trust-paths=/etc/ssl/trust-source:/etc/ssl/certs/ca-certificates.crt" + mesonFlags = [ + "-Dsystem_config=/etc" + "-Dtrust_paths=/etc/ssl/certs/ca-certificates.crt" + "-Dsystemd=disabled" + "-Dbashcompdir=${placeholder "out"}/share/bash-completion/completions" ]; enableParallelBuilding = true; From 6fd114667d37ca9e4b8b951c21827234dbdd6f21 Mon Sep 17 00:00:00 2001 From: SCOTT-HAMILTON Date: Sun, 29 Aug 2021 00:38:24 +0200 Subject: [PATCH 3/3] p11-kit: fix static build --- pkgs/development/libraries/p11-kit/default.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/p11-kit/default.nix b/pkgs/development/libraries/p11-kit/default.nix index fb762f44a75c5..e0cc1b421a8bf 100644 --- a/pkgs/development/libraries/p11-kit/default.nix +++ b/pkgs/development/libraries/p11-kit/default.nix @@ -1,8 +1,8 @@ { lib, stdenv, fetchFromGitHub, meson, ninja, pkg-config, which -, gettext, libffi, libiconv, libtasn1, bash-completion +, gettext, libffi, libiconv, libtasn1, bash-completion, mesonShlibsToStaticHook }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (rec { pname = "p11-kit"; version = "0.24.0"; @@ -21,7 +21,8 @@ stdenv.mkDerivation rec { # at the same time, libtasn1 in buildInputs provides the libasn1 library # to link against for the target platform. # hence, libtasn1 is required in both native and build inputs. - nativeBuildInputs = [ meson ninja pkg-config which libtasn1 ]; + nativeBuildInputs = [ meson ninja pkg-config which libtasn1 gettext ] ++ + lib.optional (stdenv.hostPlatform.isStatic) [ mesonShlibsToStaticHook ]; buildInputs = [ gettext libffi libiconv libtasn1 ]; propagatedBuildInputs = [ bash-completion ]; @@ -58,4 +59,8 @@ stdenv.mkDerivation rec { platforms = platforms.all; license = licenses.bsd3; }; -} +} // lib.optionalAttrs stdenv.hostPlatform.isStatic { + postPatch = '' + sed -i '/install_data(pkcs11_conf_example/,+1d' p11-kit/meson.build + ''; +})