From 3e678d5d9cf83868f39bc2962c5fe76d94cdeba2 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sat, 23 Mar 2024 14:13:02 -0400 Subject: [PATCH] tomato-c: fix build on Darwin - Add patch for missing function declarations; - Define `_ISOC99_SOURCE`, which is needed for `snprintf` on Darwin; and - Make sure TOMATONOISE points to `$out/tomatonoise` not `/usr/local/bin/tomatonoise`. --- pkgs/applications/misc/tomato-c/default.nix | 25 ++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/pkgs/applications/misc/tomato-c/default.nix b/pkgs/applications/misc/tomato-c/default.nix index 9f87712399f2..243b21b574ef 100644 --- a/pkgs/applications/misc/tomato-c/default.nix +++ b/pkgs/applications/misc/tomato-c/default.nix @@ -1,6 +1,7 @@ { lib , stdenv , fetchFromGitHub +, fetchpatch , libnotify , makeWrapper , mpv @@ -19,15 +20,26 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-RpKkQ7xhM2XqfZdXra0ju0cTBL3Al9NMVQ/oleFydDs="; }; + patches = [ + # Adds missing function declarations required by newer versions of clang. + (fetchpatch { + url = "https://github.com/gabrielzschmitz/Tomato.C/commit/ad6d4c385ae39d655a716850653cd92431c1f31e.patch"; + hash = "sha256-3ormv59Ce4rOmeyL30QET3CCUIOrRYMquub+eIQsMW8="; + }) + ]; + postPatch = '' substituteInPlace Makefile \ - --replace "sudo " "" + --replace-fail "sudo " "" + # Need to define _ISOC99_SOURCE to use `snprintf` on Darwin + substituteInPlace config.mk \ + --replace-fail -D_POSIX_C_SOURCE -D_ISOC99_SOURCE substituteInPlace notify.c \ - --replace "/usr/local" "${placeholder "out"}" + --replace-fail "/usr/local" "${placeholder "out"}" substituteInPlace util.c \ - --replace "/usr/local" "${placeholder "out"}" + --replace-fail "/usr/local" "${placeholder "out"}" substituteInPlace tomato.desktop \ - --replace "/usr/local" "${placeholder "out"}" + --replace-fail "/usr/local" "${placeholder "out"}" ''; nativeBuildInputs = [ @@ -41,8 +53,11 @@ stdenv.mkDerivation (finalAttrs: { ncurses ]; - installFlags = [ + makeFlags = [ "PREFIX=${placeholder "out"}" + ]; + + installFlags = [ "CPPFLAGS=$NIX_CFLAGS_COMPILE" "LDFLAGS=$NIX_LDFLAGS" ];