termite: Add support for macOS (#43415)

Replace fetchgit with fetchFromGitHub now that it supports fetching
submodules. Remove unnecessary postPatch to add <math.h> as termite
already includes <cmath>. Add a patch to include <errno.h> on all
platforms and remove the --as-needed flag from ld on macOS.

authored by Michael Hoang and committed by xeji d73fac6b 1e4cd7a8

+57 -7
+24
pkgs/applications/misc/termite/add_errno_header.patch
··· 1 + From 95c90f302c384f410dc92e64468ac7061b57fe2d Mon Sep 17 00:00:00 2001 2 + From: Michael Hoang <enzime@users.noreply.github.com> 3 + Date: Fri, 13 Jul 2018 19:03:09 +1000 4 + Subject: [PATCH] Add errno.h header which isn't always included automatically. 5 + 6 + --- 7 + termite.cc | 1 + 8 + 1 file changed, 1 insertion(+) 9 + 10 + diff --git a/termite.cc b/termite.cc 11 + index 160fe82..13e2572 100644 12 + --- a/termite.cc 13 + +++ b/termite.cc 14 + @@ -21,6 +21,7 @@ 15 + #include <cstdlib> 16 + #include <cstring> 17 + #include <cmath> 18 + +#include <errno.h> 19 + #include <functional> 20 + #include <limits> 21 + #include <map> 22 + -- 23 + 2.17.1 24 +
+8 -7
pkgs/applications/misc/termite/default.nix
··· 1 - { stdenv, fetchgit, pkgconfig, vte, gtk3, ncurses, makeWrapper, wrapGAppsHook, symlinkJoin 1 + { stdenv, fetchFromGitHub, lib, pkgconfig, vte, gtk3, ncurses, makeWrapper, wrapGAppsHook, symlinkJoin 2 2 , configFile ? null 3 3 }: 4 4 ··· 7 7 termite = stdenv.mkDerivation { 8 8 name = "termite-${version}"; 9 9 10 - src = fetchgit { 11 - url = "https://github.com/thestinger/termite"; 12 - rev = "refs/tags/v${version}"; 10 + src = fetchFromGitHub { 11 + owner = "thestinger"; 12 + repo = "termite"; 13 + rev = "v${version}"; 13 14 sha256 = "02cn70ygl93ghhkhs3xdxn5b1yadc255v3yp8cmhhyzsv5027hvj"; 15 + fetchSubmodules = true; 14 16 }; 15 17 16 18 # https://github.com/thestinger/termite/pull/516 17 - patches = [ ./url_regexp_trailing.patch ]; 18 - 19 - postPatch = "sed '1i#include <math.h>' -i termite.cc"; 19 + patches = [ ./url_regexp_trailing.patch ./add_errno_header.patch 20 + ] ++ lib.optional stdenv.isDarwin ./remove_ldflags_macos.patch; 20 21 21 22 makeFlags = [ "VERSION=v${version}" "PREFIX=" "DESTDIR=$(out)" ]; 22 23
+25
pkgs/applications/misc/termite/remove_ldflags_macos.patch
··· 1 + From 1b5a6934635c55472eb7949bd87ab3f45fa1b2f3 Mon Sep 17 00:00:00 2001 2 + From: Michael Hoang <enzime@users.noreply.github.com> 3 + Date: Fri, 13 Jul 2018 19:01:51 +1000 4 + Subject: [PATCH] Remove --as-needed flag from ld to fix compilation on macOS. 5 + 6 + --- 7 + Makefile | 2 +- 8 + 1 file changed, 1 insertion(+), 1 deletion(-) 9 + 10 + diff --git a/Makefile b/Makefile 11 + index b115f42..ab301ba 100644 12 + --- a/Makefile 13 + +++ b/Makefile 14 + @@ -29,7 +29,7 @@ ifeq (${CXX}, clang++) 15 + CXXFLAGS += -Wimplicit-fallthrough 16 + endif 17 + 18 + -LDFLAGS := -s -Wl,--as-needed ${LDFLAGS} 19 + +LDFLAGS := -s -Wl ${LDFLAGS} 20 + LDLIBS := ${shell pkg-config --libs ${GTK} ${VTE}} 21 + 22 + termite: termite.cc url_regex.hh util/clamp.hh util/maybe.hh util/memory.hh 23 + -- 24 + 2.17.1 25 +