From aa9f915f4d964734350d5f25aa0fb33f489314c7 Mon Sep 17 00:00:00 2001 From: Alois Wohlschlager Date: Tue, 23 Sep 2025 20:04:00 +0200 Subject: [PATCH 1/2] nghttp3: fix static build When a static build is requested, actually build a static library, and don't try to build a dynamic library. Otherwise the build will fail with linker errors (not that it would be any more correct if it succeeded): /nix/store/yh6s1ihxlxcdb4ihxm7zvk9356jsl8nw-x86_64-unknown-linux-musl-binutils-2.44/bin/x86_64-unknown-linux-musl-ld: /nix/store/2jz1w0ffkf4ggs0ihyb0cpfgm3nka0p4-x86_64-unknown-linux-musl-gcc-14.3.0/lib/gcc/x86_64-unknown-linux-musl/14.3.0/crtbeginT.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object /nix/store/yh6s1ihxlxcdb4ihxm7zvk9356jsl8nw-x86_64-unknown-linux-musl-binutils-2.44/bin/x86_64-unknown-linux-musl-ld: failed to set dynamic section sizes: bad value --- pkgs/by-name/ng/nghttp3/package.nix | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/ng/nghttp3/package.nix b/pkgs/by-name/ng/nghttp3/package.nix index 784e5c3ecf6a..3b9b0098765a 100644 --- a/pkgs/by-name/ng/nghttp3/package.nix +++ b/pkgs/by-name/ng/nghttp3/package.nix @@ -23,9 +23,16 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ cmake ]; - cmakeFlags = [ - (lib.cmakeBool "ENABLE_STATIC_LIB" false) - ]; + cmakeFlags = + if stdenv.hostPlatform.isStatic then + [ + (lib.cmakeBool "ENABLE_SHARED_LIB" false) + (lib.cmakeBool "ENABLE_STATIC_LIB" true) + ] + else + [ + (lib.cmakeBool "ENABLE_STATIC_LIB" false) + ]; doCheck = true; From f661657f60fcc628fcf7fb4277d8746c9c5b773a Mon Sep 17 00:00:00 2001 From: Alois Wohlschlager Date: Tue, 23 Sep 2025 20:09:12 +0200 Subject: [PATCH 2/2] ngtcp2: fix static build --- pkgs/development/libraries/ngtcp2/default.nix | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/ngtcp2/default.nix b/pkgs/development/libraries/ngtcp2/default.nix index bf595f473050..9de9314dc37d 100644 --- a/pkgs/development/libraries/ngtcp2/default.nix +++ b/pkgs/development/libraries/ngtcp2/default.nix @@ -36,9 +36,19 @@ stdenv.mkDerivation (finalAttrs: { ] ++ lib.optional withJemalloc jemalloc; - cmakeFlags = [ - (lib.cmakeBool "ENABLE_STATIC_LIB" false) - ]; + cmakeFlags = + if stdenv.hostPlatform.isStatic then + [ + # The examples try to link against `ngtcp2_crypto_ossl` and `ngtcp2` libraries. + # This works in the dynamic case where the targets have the same name, but not here where they're suffixed with `_static`. + (lib.cmakeBool "ENABLE_LIB_ONLY" true) + (lib.cmakeBool "ENABLE_SHARED_LIB" false) + (lib.cmakeBool "ENABLE_STATIC_LIB" true) + ] + else + [ + (lib.cmakeBool "ENABLE_STATIC_LIB" false) + ]; doCheck = true;