From f15d9c9c1e405fa4e9810b1088e41e5db0c0f2f3 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Fri, 1 Mar 2024 11:12:30 +1300 Subject: [PATCH] chawan: init at 0-unstable-2024-03-01 --- .../ch/chawan/mancha-augment-path.diff | 15 ++++ pkgs/by-name/ch/chawan/package.nix | 76 +++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 pkgs/by-name/ch/chawan/mancha-augment-path.diff create mode 100644 pkgs/by-name/ch/chawan/package.nix diff --git a/pkgs/by-name/ch/chawan/mancha-augment-path.diff b/pkgs/by-name/ch/chawan/mancha-augment-path.diff new file mode 100644 index 000000000000..cbe4f6aed80e --- /dev/null +++ b/pkgs/by-name/ch/chawan/mancha-augment-path.diff @@ -0,0 +1,15 @@ +Add the -m option to man's command line to augment the list of paths +searched by man. The string "OUT" must be substituted with chawan's $out +path after patching. +The required -m option is only available in the mandoc implementation. +--- a/adapter/protocol/man ++++ b/adapter/protocol/man +@@ -75,7 +75,7 @@ EOF + + $section =~ s:([^-\w\200-\377.,])::g; + $man =~ s:([^-\w\200-\377.,])::g; +- open(F, "GROFF_NO_SGR=1 MAN_KEEP_FORMATTING=1 $MAN $section $man 2> /dev/null |"); ++ open(F, "GROFF_NO_SGR=1 MAN_KEEP_FORMATTING=1 $MAN -m OUT/share/man $section $man 2> /dev/null |"); + } + + $ok = 0; diff --git a/pkgs/by-name/ch/chawan/package.nix b/pkgs/by-name/ch/chawan/package.nix new file mode 100644 index 000000000000..4a52e998fc7c --- /dev/null +++ b/pkgs/by-name/ch/chawan/package.nix @@ -0,0 +1,76 @@ +{ lib +, stdenv +, fetchFromSourcehut +, makeBinaryWrapper +, curlMinimal +, mandoc +, ncurses +, nim +, pandoc +, perl +, pkg-config +, zlib +}: + +stdenv.mkDerivation { + pname = "chawan"; + version = "0-unstable-2024-03-01"; + + src = fetchFromSourcehut { + owner = "~bptato"; + repo = "chawan"; + rev = "87ba9a87be15abbe06837f1519cfb76f4bf759f3"; + hash = "sha256-Xs+Mxe5/uoxPMf4FuelpO+bRJ1KdfASVI7rWqtboJZw="; + fetchSubmodules = true; + }; + + patches = [ + # Include chawan's man pages in mancha's search path + ./mancha-augment-path.diff + ]; + + env.NIX_CFLAGS_COMPILE = toString ( + lib.optional stdenv.cc.isClang "-Wno-error=implicit-function-declaration" + ); + + buildInputs = [ curlMinimal ncurses perl zlib ]; + nativeBuildInputs = [ + makeBinaryWrapper + nim + pandoc + pkg-config + ]; + + postPatch = '' + substituteInPlace adapter/protocol/man \ + --replace-fail "OUT" $out + ''; + + buildFlags = [ "all" "manpage" ]; + installFlags = [ + "DESTDIR=$(out)" + "PREFIX=/" + ]; + + postInstall = + let + makeWrapperArgs = '' + --set MANCHA_CHA $out/bin/cha \ + --set MANCHA_MAN ${mandoc}/bin/man + ''; + in + '' + wrapProgram $out/bin/cha ${makeWrapperArgs} + wrapProgram $out/bin/mancha ${makeWrapperArgs} + ''; + + meta = { + description = "Lightweight and featureful terminal web browser"; + homepage = "https://sr.ht/~bptato/chawan/"; + license = lib.licenses.publicDomain; + platforms = lib.platforms.unix; + maintainers = with lib.maintainers; [ jtbx ]; + mainProgram = "cha"; + broken = stdenv.isDarwin; # pending PR #292043 + }; +}