about summary refs log tree commit diff
path: root/pkgs/tools/text
diff options
context:
space:
mode:
authorDmitry Kalinkin <dmitry.kalinkin@gmail.com>2021-09-15 11:49:55 -0400
committerGitHub <noreply@github.com>2021-09-15 11:49:55 -0400
commitd8ed39b309bf6fc4261a46d1ca6d218e791dc0e2 (patch)
tree2c78e54a00197ce0d898cf21af6bcea94a6245be /pkgs/tools/text
parentf8cea6b5bc823b5e416fc4f615c97b57f14ac942 (diff)
parent9c8f6efc550a04213236c308bc2f88d176527efa (diff)
Merge pull request #135525 from veprbl/pr/open_memstream_fmemopen_darwin_fix
Add implemetations of open_memstream/fmemopen to be used on BSDs
Diffstat (limited to 'pkgs/tools/text')
-rw-r--r--pkgs/tools/text/hyx/default.nix17
-rw-r--r--pkgs/tools/text/hyx/memstream.patch31
2 files changed, 6 insertions, 42 deletions
diff --git a/pkgs/tools/text/hyx/default.nix b/pkgs/tools/text/hyx/default.nix
index c2b055be7df94..c287b37dd1b57 100644
--- a/pkgs/tools/text/hyx/default.nix
+++ b/pkgs/tools/text/hyx/default.nix
@@ -1,11 +1,5 @@
-{ lib, stdenv, fetchurl }:
-let
-  # memstream — POSIX memory streams for BSD
-  memstream = fetchurl {
-    url = "https://piumarta.com/software/memstream/memstream-0.1.tar.gz";
-    sha256 = "0kvdb897g7nyviaz72arbqijk2g2wa61cmi3l5yh48rzr49r3a3a";
-  };
-in
+{ lib, stdenv, fetchurl, memstreamHook }:
+
 stdenv.mkDerivation rec {
   pname = "hyx";
   version = "2020-06-09";
@@ -15,11 +9,12 @@ stdenv.mkDerivation rec {
     sha256 = "1x8dmll93hrnj24kn5knpwj36y6r1v2ygwynpjwrg2hwd4c1a8hi";
   };
 
-  postUnpack = lib.optionalString stdenv.isDarwin ''
-    tar --strip=1 -C $sourceRoot -xf ${memstream} --wildcards "memstream-0.1/memstream.[hc]"
+  postPatch = lib.optionalString stdenv.isDarwin ''
+    substituteInPlace Makefile \
+      --replace "-Wl,-z,relro,-z,now -fpic -pie" ""
   '';
 
-  patches = lib.optional stdenv.isDarwin ./memstream.patch;
+  buildInputs = lib.optional (stdenv.system == "x86_64-darwin") memstreamHook;
 
   installPhase = ''
     install -vD hyx $out/bin/hyx
diff --git a/pkgs/tools/text/hyx/memstream.patch b/pkgs/tools/text/hyx/memstream.patch
deleted file mode 100644
index a02509ced762a..0000000000000
--- a/pkgs/tools/text/hyx/memstream.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-diff -Naur hyx-2020.06.09.org/Makefile hyx-2020.06.09/Makefile
---- hyx-2020.06.09.org/Makefile	2020-06-09 15:19:50.000000000 +0300
-+++ hyx-2020.06.09/Makefile	2020-07-22 11:46:40.000000000 +0300
-@@ -1,6 +1,6 @@
- 
- all: CFLAGS ?= -O2 -Wl,-s \
--               -Wl,-z,relro,-z,now -fpic -pie -D_FORTIFY_SOURCE=2 -fstack-protector-all
-+               -D_FORTIFY_SOURCE=2 -fstack-protector-all
- all: CFLAGS += -std=c99 -pedantic -Wall -Wextra -DNDEBUG
- all: hyx
- 
-@@ -13,7 +13,7 @@
- hyx: *.h *.c
- 	$(CC) \
- 		$(CFLAGS) \
--		hyx.c common.c blob.c history.c view.c input.c \
-+		hyx.c common.c blob.c history.c view.c input.c memstream.c \
- 		-o hyx
- 
- clean:
-diff -Naur hyx-2020.06.09.org/view.c hyx-2020.06.09/view.c
---- hyx-2020.06.09.org/view.c	2020-06-09 15:19:50.000000000 +0300
-+++ hyx-2020.06.09/view.c	2020-07-22 11:49:09.000000000 +0300
-@@ -4,6 +4,7 @@
- #include "view.h"
- #include "input.h"
- #include "ansi.h"
-+#include "memstream.h"
- 
- #include <stdlib.h>
- #include <stdio.h>