From 2a1cae7c678def180f6e5a54a7c0150e43d415b5 Mon Sep 17 00:00:00 2001 From: phibkro <71797726+phibkro@users.noreply.github.com> Date: Fri, 5 Jun 2026 11:49:36 +0200 Subject: [PATCH] cpufetch: fix x86_64-darwin build (add sysctl.c on Darwin too) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Hydra failure on x86_64-darwin (build 330211579) bails at link time with: Undefined symbols for architecture x86_64: "_get_sys_info_by_name", referenced from: _get_frequency_info in cpuid-XXX.o `get_sys_info_by_name` is defined in `src/common/sysctl.c` and called from `src/x86/cpuid.c:979` (for CPU-frequency detection via sysctl). Upstream's Makefile adds `sysctl.c` to SOURCE only inside the `ifeq ($(os), FreeBSD)` block of the x86 branch — Darwin x86_64 falls through without the source, so the link breaks. Widen the conditional to `$(filter $(os),FreeBSD Darwin)`. Patched via a small .patch file (cleaner than escaping `$$` through nix + bash + make). Build now compiles `src/common/sysctl.c` and links cleanly; `cpufetch` runs on macOS 15.6.1 Sequoia and prints the Intel banner. x86_64-linux unaffected — `patches` only applies on darwin. Fixes https://hydra.nixos.org/build/330211579 Assisted-by: Claude Opus 4.7 --- pkgs/by-name/cp/cpufetch/darwin-x86-sysctl.patch | 11 +++++++++++ pkgs/by-name/cp/cpufetch/package.nix | 9 +++++++++ 2 files changed, 20 insertions(+) create mode 100644 pkgs/by-name/cp/cpufetch/darwin-x86-sysctl.patch diff --git a/pkgs/by-name/cp/cpufetch/darwin-x86-sysctl.patch b/pkgs/by-name/cp/cpufetch/darwin-x86-sysctl.patch new file mode 100644 index 000000000000..a5644516fd5c --- /dev/null +++ b/pkgs/by-name/cp/cpufetch/darwin-x86-sysctl.patch @@ -0,0 +1,11 @@ +--- a/Makefile ++++ b/Makefile +@@ -30,7 +30,7 @@ + HEADERS += $(SRC_DIR)freq/freq.h + CFLAGS += -pthread + endif +- ifeq ($(os), FreeBSD) ++ ifneq (,$(filter $(os),FreeBSD Darwin)) + SOURCE += $(SRC_COMMON)sysctl.c + HEADERS += $(SRC_COMMON)sysctl.h + endif diff --git a/pkgs/by-name/cp/cpufetch/package.nix b/pkgs/by-name/cp/cpufetch/package.nix index 9ccd5a422957..cd046f27b87a 100644 --- a/pkgs/by-name/cp/cpufetch/package.nix +++ b/pkgs/by-name/cp/cpufetch/package.nix @@ -20,6 +20,15 @@ stdenv.mkDerivation (finalAttrs: { installShellFiles ]; + # Upstream Makefile bug: for x86 builds, sysctl.c is only added to + # SOURCE on FreeBSD even though cpuid.c calls get_sys_info_by_name + # (defined there) on darwin too. Without this the x86_64-darwin + # build fails to link with "Undefined symbols: _get_sys_info_by_name". + # Widen the conditional to cover Darwin alongside FreeBSD. + patches = lib.optionals stdenv.hostPlatform.isDarwin [ + ./darwin-x86-sysctl.patch + ]; + installPhase = '' runHook preInstall