summary refs log tree commit diff
path: root/pkgs/tools/text
diff options
context:
space:
mode:
authorNikolay Korotkiy <sikmir@gmail.com>2020-07-22 12:35:54 +0300
committerNikolay Korotkiy <sikmir@gmail.com>2020-07-22 13:10:08 +0300
commitf585a26878ea415e3b2c65b34fe1bdf5e5559795 (patch)
tree420f22ee673774154af0fe3087eb5a2b4b10b54d /pkgs/tools/text
parentfe6c0ff6b2bbd1f1b1485d32867536fdf9042d3e (diff)
downloadnixpkgs-f585a26878ea415e3b2c65b34fe1bdf5e5559795.tar
nixpkgs-f585a26878ea415e3b2c65b34fe1bdf5e5559795.tar.gz
nixpkgs-f585a26878ea415e3b2c65b34fe1bdf5e5559795.tar.bz2
nixpkgs-f585a26878ea415e3b2c65b34fe1bdf5e5559795.tar.lz
nixpkgs-f585a26878ea415e3b2c65b34fe1bdf5e5559795.tar.xz
nixpkgs-f585a26878ea415e3b2c65b34fe1bdf5e5559795.tar.zst
nixpkgs-f585a26878ea415e3b2c65b34fe1bdf5e5559795.zip
hyx: enable on darwin
Diffstat (limited to 'pkgs/tools/text')
-rw-r--r--pkgs/tools/text/hyx/default.nix16
-rw-r--r--pkgs/tools/text/hyx/memstream.patch31
2 files changed, 45 insertions, 2 deletions
diff --git a/pkgs/tools/text/hyx/default.nix b/pkgs/tools/text/hyx/default.nix
index 6553e935fe8..c2b055be7df 100644
--- a/pkgs/tools/text/hyx/default.nix
+++ b/pkgs/tools/text/hyx/default.nix
@@ -1,5 +1,11 @@
 { 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
 stdenv.mkDerivation rec {
   pname = "hyx";
   version = "2020-06-09";
@@ -9,6 +15,12 @@ stdenv.mkDerivation rec {
     sha256 = "1x8dmll93hrnj24kn5knpwj36y6r1v2ygwynpjwrg2hwd4c1a8hi";
   };
 
+  postUnpack = lib.optionalString stdenv.isDarwin ''
+    tar --strip=1 -C $sourceRoot -xf ${memstream} --wildcards "memstream-0.1/memstream.[hc]"
+  '';
+
+  patches = lib.optional stdenv.isDarwin ./memstream.patch;
+
   installPhase = ''
     install -vD hyx $out/bin/hyx
   '';
@@ -18,6 +30,6 @@ stdenv.mkDerivation rec {
     homepage = "https://yx7.cc/code/";
     license = licenses.mit;
     maintainers = with maintainers; [ fpletz ];
-    platforms = platforms.linux;
+    platforms = with platforms; linux ++ darwin;
   };
 }
diff --git a/pkgs/tools/text/hyx/memstream.patch b/pkgs/tools/text/hyx/memstream.patch
new file mode 100644
index 00000000000..a02509ced76
--- /dev/null
+++ b/pkgs/tools/text/hyx/memstream.patch
@@ -0,0 +1,31 @@
+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>