From fc3665f74a7b9f8a8a241bc783d8817a826d452b Mon Sep 17 00:00:00 2001 From: WilliButz Date: Mon, 3 Nov 2025 13:50:24 +0100 Subject: [PATCH 1/2] botan3: fix selection of stdenv variant for static builds Apparently with the move to by-name broke stdenv selection in such a way that the resulting library archive from `pkgsStatic.botan3` no longer was suitable for static linking, resulting in linking errors: ``` /nix/store/<...>-x86_64-unknown-linux-musl-binutils-2.44/bin/x86_64-unknown-linux-musl-ld: cannot find -lbz2: No such file /nix/store/<...>-x86_64-unknown-linux-musl-binutils-2.44/bin/x86_64-unknown-linux-musl-ld: have you installed the static ve /nix/store/<...>-x86_64-unknown-linux-musl-binutils-2.44/bin/x86_64-unknown-linux-musl-ld: cannot find -ljitterentropy: No /nix/store/<...>-x86_64-unknown-linux-musl-binutils-2.44/bin/x86_64-unknown-linux-musl-ld: have you installed the static ve /nix/store/<...>-x86_64-unknown-linux-musl-binutils-2.44/bin/x86_64-unknown-linux-musl-ld: cannot find -lz: No such file or /nix/store/<...>-x86_64-unknown-linux-musl-binutils-2.44/bin/x86_64-unknown-linux-musl-ld: have you installed the static ve ``` Co-authored-by: Maximilian Bosch --- pkgs/by-name/bo/botan3/package.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pkgs/by-name/bo/botan3/package.nix b/pkgs/by-name/bo/botan3/package.nix index 084eb1face8b..df822c92caa7 100644 --- a/pkgs/by-name/bo/botan3/package.nix +++ b/pkgs/by-name/bo/botan3/package.nix @@ -1,7 +1,7 @@ { lib, stdenv, - buildPackages, + libcxxStdenv, fetchurl, pkgsStatic, python3, @@ -9,7 +9,6 @@ bzip2, zlib, jitterentropy, - darwin, esdm, tpm2-tss, static ? stdenv.hostPlatform.isStatic, # generates static libraries *only* @@ -20,7 +19,7 @@ # useful, but have to disable tests for now, as /dev/tpmrm0 is not accessible withTpm2 ? false, policy ? null, -}: +}@args: assert lib.assertOneOf "policy" policy [ # no explicit policy is given. The defaults by the library are used @@ -32,11 +31,10 @@ assert lib.assertOneOf "policy" policy [ # only allow "modern" algorithms "modern" ]; - let - stdenv' = if static then buildPackages.libcxxStdenv else stdenv; + stdenv = if static then libcxxStdenv else args.stdenv; in -stdenv'.mkDerivation (finalAttrs: { +stdenv.mkDerivation (finalAttrs: { version = "3.9.0"; pname = "botan"; From c8a230069b95520abc24a2c3daa51956e21411a8 Mon Sep 17 00:00:00 2001 From: WilliButz Date: Mon, 3 Nov 2025 11:44:45 +0100 Subject: [PATCH 2/2] botan3: fix static cli build through empty-libgcc_eh workaround Prior to this commit the build of `pkgsStatic.botan3.bin` produced a dynamically linked binary, indenpendently of the move to `pkgs/by-name`. Previous commit message and comments also suggest this it was expected for the static build to only produce the static library, not the statically linked cli. --- pkgs/by-name/bo/botan3/package.nix | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/bo/botan3/package.nix b/pkgs/by-name/bo/botan3/package.nix index df822c92caa7..04fdafff9153 100644 --- a/pkgs/by-name/bo/botan3/package.nix +++ b/pkgs/by-name/bo/botan3/package.nix @@ -4,6 +4,8 @@ libcxxStdenv, fetchurl, pkgsStatic, + runCommandLocal, + binutils, python3, docutils, bzip2, @@ -11,7 +13,7 @@ jitterentropy, esdm, tpm2-tss, - static ? stdenv.hostPlatform.isStatic, # generates static libraries *only* + static ? stdenv.hostPlatform.isStatic, windows, # build ESDM RNG plugin @@ -33,6 +35,21 @@ assert lib.assertOneOf "policy" policy [ ]; let stdenv = if static then libcxxStdenv else args.stdenv; + + # (based on same workaround from capnproto package) + # + # HACK: work around https://github.com/NixOS/nixpkgs/issues/177129 + # Though this is an issue between Clang and GCC, + # so it may not get fixed anytime soon... + empty-libgcc_eh = + runCommandLocal "empty-libgcc_eh" + { + nativeBuildInputs = [ binutils ]; + } + '' + mkdir -p "$out"/lib + ${stdenv.cc.targetPrefix}ar r "$out"/lib/libgcc_eh.a + ''; in stdenv.mkDerivation (finalAttrs: { version = "3.9.0"; @@ -80,6 +97,8 @@ stdenv.mkDerivation (finalAttrs: { windows.pthreads ]; + propagatedBuildInputs = lib.optional static empty-libgcc_eh; + buildTargets = [ "cli" ]