about summary refs log tree commit diff
path: root/pkgs/sternenseemann
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-02-08 23:13:01 +0100
committersternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-02-09 11:49:14 +0100
commit3601fa5464c7501719f23bfe56de5842a9e83b6c (patch)
treeef5f819492978e09aa6df6bdf469ac7234fccace /pkgs/sternenseemann
parent85a6cdcd9270708e2ae88485cbf243b620c9cb0a (diff)
pkgs/sternenseemann/mandoc: init
Build mandoc from cvs and apply a patch which adds an exception for
the checks does makewhatis(8): with this the realpaths of man pages to
be indexed may be symlinks referring to files outside of the root man
directory if they are located in /nix/store.

This allows indexing /run/current-system/sw/share/man using mandoc's
makewhatis(8).

Since fetchcvs is currently broken in nixos-unstable we vendor in the
fixed variant from nixpkgs master until the channel has advanced.
Diffstat (limited to 'pkgs/sternenseemann')
-rw-r--r--pkgs/sternenseemann/default.nix21
-rw-r--r--pkgs/sternenseemann/fetchcvs/builder.sh27
-rw-r--r--pkgs/sternenseemann/fetchcvs/default.nix20
-rw-r--r--pkgs/sternenseemann/patches/mandoc-nix-store.patch75
4 files changed, 143 insertions, 0 deletions
diff --git a/pkgs/sternenseemann/default.nix b/pkgs/sternenseemann/default.nix
index a6e3a3bb..984afa5b 100644
--- a/pkgs/sternenseemann/default.nix
+++ b/pkgs/sternenseemann/default.nix
@@ -33,6 +33,10 @@ let
     };
   };
 
+  # temporarily vendor the fixed fetchcvs builder
+  # from nixpkgs master
+  fetchcvs = callPackage ./fetchcvs { };
+
 in
 
 lib.fix (self: {
@@ -42,6 +46,23 @@ lib.fix (self: {
 
   logbook = ocamlPackages.callPackage ./logbook { };
 
+  mandoc = pkgs.mandoc.overrideAttrs (old: rec {
+    src = fetchcvs {
+      sha256 = "19cqasw7fjsmhshs5khxrv8w3vdhf8xadls70l0gzqn7cyjmgsb9";
+      date = "2021-02-07";
+      cvsRoot = "anoncvs@mandoc.bsd.lv:/cvs";
+      module = "mandoc";
+    };
+    version = "unstable-${src.date}"; # actually early but idc
+    # fix makewhatis(1) skipping all man pages that
+    # are symlinks to /nix/store
+    patches = [ ./patches/mandoc-nix-store.patch ];
+    patchFlags = [ "-p0" ];
+    preConfigure = old.preConfigure + ''
+      echo NIXSTOREDIR="$(dirname "$out")" >> configure.local
+    '';
+  });
+
   pass = (pkgs.pass.override {
     waylandSupport = true;
     x11Support = false;
diff --git a/pkgs/sternenseemann/fetchcvs/builder.sh b/pkgs/sternenseemann/fetchcvs/builder.sh
new file mode 100644
index 00000000..fe1019aa
--- /dev/null
+++ b/pkgs/sternenseemann/fetchcvs/builder.sh
@@ -0,0 +1,27 @@
+source $stdenv/setup
+
+(echo "#!$SHELL"; \
+ echo 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$@"') > ssh
+chmod +x ssh
+export CVS_RSH=$PWD/ssh
+
+# creating the export drictory and checking out there only to be able to
+# move the content without the root directory into $out ...
+# cvs -f -d "$url" export $tag -d "$out" "$module"
+# should work (but didn't - got no response on #cvs)
+# See als man Page for those options
+
+mkdir -p export
+if [ -n "$tag" ]; then
+    tag="-r $tag"
+else
+    if [ -n "$date" ]; then
+        tag="-D $date"
+    else
+        tag="-D NOW"
+    fi
+fi
+(cd export && cvs -f -z0 -d "$cvsRoot" export $tag "$module")
+mv export/* $out
+
+stopNest
diff --git a/pkgs/sternenseemann/fetchcvs/default.nix b/pkgs/sternenseemann/fetchcvs/default.nix
new file mode 100644
index 00000000..1f7947d4
--- /dev/null
+++ b/pkgs/sternenseemann/fetchcvs/default.nix
@@ -0,0 +1,20 @@
+# example tags:
+# date="2007-20-10"; (get the last version before given date)
+# tag="<tagname>" (get version by tag name)
+# If you don't specify neither one date="NOW" will be used (get latest)
+
+{stdenvNoCC, cvs, openssh}:
+
+{cvsRoot, module, tag ? null, date ? null, sha256}:
+
+stdenvNoCC.mkDerivation {
+  name = "cvs-export";
+  builder = ./builder.sh;
+  nativeBuildInputs = [cvs openssh];
+
+  outputHashAlgo = "sha256";
+  outputHashMode = "recursive";
+  outputHash = sha256;
+
+  inherit cvsRoot module sha256 tag date;
+}
diff --git a/pkgs/sternenseemann/patches/mandoc-nix-store.patch b/pkgs/sternenseemann/patches/mandoc-nix-store.patch
new file mode 100644
index 00000000..22be8fcc
--- /dev/null
+++ b/pkgs/sternenseemann/patches/mandoc-nix-store.patch
@@ -0,0 +1,75 @@
+Index: configure
+===================================================================
+RCS file: /cvs/mandoc/configure,v
+retrieving revision 1.77
+diff -u -r1.77 configure
+--- configure	20 Jul 2020 16:57:30 -0000	1.77
++++ configure	8 Feb 2021 17:51:07 -0000
+@@ -108,6 +108,7 @@
+ LIBDIR=
+ MANDIR=
+ HOMEBREWDIR=
++NIXSTOREDIR=
+ 
+ WWWPREFIX="/var/www"
+ HTDOCDIR=
+@@ -462,6 +463,7 @@
+ [ -n "${OSNAME}" ] && echo "#define OSNAME \"${OSNAME}\""
+ [ -n "${UTF8_LOCALE}" ] && echo "#define UTF8_LOCALE \"${UTF8_LOCALE}\""
+ [ -n "${HOMEBREWDIR}" ] && echo "#define HOMEBREWDIR \"${HOMEBREWDIR}\""
++[ -n "${NIXSTOREDIR}" ] && echo "#define NIXSTOREDIR \"${NIXSTOREDIR}\""
+ [ ${HAVE_ATTRIBUTE} -eq 0 ] && echo "#define __attribute__(x)"
+ [ ${HAVE_EFTYPE} -eq 0 ] && echo "#define EFTYPE EINVAL"
+ [ ${HAVE_O_DIRECTORY} -eq 0 ] && echo "#define O_DIRECTORY 0"
+Index: configure.local.example
+===================================================================
+RCS file: /cvs/mandoc/configure.local.example,v
+retrieving revision 1.39
+diff -u -r1.39 configure.local.example
+--- configure.local.example	20 Jul 2020 16:57:30 -0000	1.39
++++ configure.local.example	8 Feb 2021 17:51:07 -0000
+@@ -218,6 +218,16 @@
+ PREFIX="/usr/local"
+ HOMEBREWDIR="${PREFIX}/Cellar"
+ 
++# Similarly, when using the nix package manager or the NixOS linux
++# distribution, man pages are stored in the packages' output store
++# path in /nix/store.  The globally installed man pages under
++# /run/current-system/sw/share/man are thus symlinks to files under
++# /nix/store.  By setting NIXSTOREDIR, mandoc won't ignore these
++# symlinks.
++# This setting can also be used to support Guix which is derived
++# from NixOS, but uses /gnu/store instead of /nix/store.
++NIXSTOREDIR="/nix/store"
++
+ # --- user settings for the mandoc(3) library --------------------------
+ 
+ # By default, libmandoc.a is not installed.  It is almost never needed
+Index: mandocdb.c
+===================================================================
+RCS file: /cvs/mandoc/mandocdb.c,v
+retrieving revision 1.267
+diff -u -r1.267 mandocdb.c
+--- mandocdb.c	3 Apr 2020 11:35:01 -0000	1.267
++++ mandocdb.c	8 Feb 2021 17:51:08 -0000
+@@ -615,6 +615,9 @@
+ #ifdef HOMEBREWDIR
+ 			    && strncmp(buf, HOMEBREWDIR, strlen(HOMEBREWDIR))
+ #endif
++#ifdef NIXSTOREDIR
++			    && strncmp(buf, NIXSTOREDIR, strlen(NIXSTOREDIR))
++#endif
+ 			) {
+ 				if (warnings) say("",
+ 				    "%s: outside base directory", buf);
+@@ -825,6 +828,10 @@
+ 		start = usefile + basedir_len;
+ #ifdef HOMEBREWDIR
+ 	else if (strncmp(usefile, HOMEBREWDIR, strlen(HOMEBREWDIR)) == 0)
++		start = usefile;
++#endif
++#ifdef NIXSTOREDIR
++	else if (strncmp(usefile, NIXSTOREDIR, strlen(NIXSTOREDIR)) == 0)
+ 		start = usefile;
+ #endif
+ 	else {