gbenchmark: fix eval and build on musl

glibcLocales is only non-null when stdenv.hostPlatform.isLinux &&
stdenv.hostPlatform.isGnu, so when it was added it broke eval of this
package on musl.  Fix the platform checks to be more accurate, and
backport an upstream fix for more accurate platform checks on their
side, to get building on musl again.

Fixes: f6da919839 ("gbenchmark: 1.9.4 -> 1.9.5")
This commit is contained in:
Alyssa Ross
2026-06-11 18:57:36 +02:00
parent 16753a2419
commit b6f477e6e7
+13 -2
View File
@@ -2,6 +2,7 @@
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
cmake,
ninja,
gtest,
@@ -20,6 +21,14 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-Mm4pG7zMB00iof32CxreoNBFnduPZTMp3reHMCIAFPQ=";
};
patches = [
(fetchpatch {
name = "portability.patch";
url = "https://github.com/google/benchmark/commit/b5ba9bab85d80f29a161dd634b7d234cf3722f90.patch";
hash = "sha256-/X01AWXK0eJ59F8oSREZ7V5Cpw1y35n9uFB1mCvMOus=";
})
];
nativeBuildInputs = [
cmake
ninja
@@ -27,7 +36,7 @@ stdenv.mkDerivation (finalAttrs: {
buildInputs = [ gtest ];
nativeCheckInputs = lib.optionals stdenv.hostPlatform.isLinux [ glibcLocales ];
nativeCheckInputs = lib.optionals (glibcLocales != null) [ glibcLocales ];
cmakeFlags = [
(lib.cmakeBool "BENCHMARK_USE_BUNDLED_GTEST" false)
@@ -45,10 +54,12 @@ stdenv.mkDerivation (finalAttrs: {
# with Xcode, but we just work around it by silencing the warning.
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-c++17-attribute-extensions";
}
// lib.optionalAttrs stdenv.hostPlatform.isLinux {
// lib.optionalAttrs stdenv.hostPlatform.isGnu {
# For test:locale_impermeability_test
LANG = "en_US.UTF-8";
LC_ALL = "en_US.UTF-8";
}
// lib.optionalAttrs (glibcLocales != null) {
LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive";
};