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