tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: sternenseemann <sternenseemann@systemli.org>
To: tech@mandoc.bsd.lv
Subject: [PATCH makewhatis] add NIXSTOREDIR configuration variable to support NixOS
Date: Tue, 30 Mar 2021 21:49:49 +0200	[thread overview]
Message-ID: <8bce7cc9-954e-1c28-ee25-13969f66eb20@systemli.org> (raw)

On NixOS there is a similar situation as with Hombrew: The actual man
pages are installed into custom prefixes for each package under
/nix/store and then symlinked to in the global share/man directory
(which is /run/current-system/sw/share/man for NixOS). This of course
makes makewhatis skip every installed man page when indexing because
/nix/store is considered outside of the man directory.

To fix this issue I've followed the implementation of HOMEBREWDIR. The
drawback of this being that more or less the same code is duplicated for
this purpose. However there may be a (arguably very small) group of
users who would possibly want to use both configuration variables at the
same time as the nix package manager can also be installed on macOS, but
it would probably also not do any harm merging the two variables into one.

This patch is necessary to provide a mandoc-based alternative to the
current documentation.man module in NixOS which uses GNU's man-db
package. I have a working implementation of this (using a cvs version of
mandoc with this patch applied) here:
https://github.com/openlab-aux/vuizvui/blob/master/modules/user/sternenseemann/documentation/mandoc.nix

A side note: During testing I haven't been able to trigger the code path
of the ifdef in filescan. I've added it anyways because HOMEBREWDIR also
has been added there, but didn't seem to be a situation where basedir is
set and filescan is called, but maybe I missed something.

cheers,
lukas


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=o				
 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 {
--
 To unsubscribe send an email to tech+unsubscribe@mandoc.bsd.lv


             reply	other threads:[~2021-03-30 19:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30 19:49 sternenseemann [this message]
2021-03-30 20:30 ` Ingo Schwarze
2021-03-30 21:03   ` sternenseemann
2021-03-31 17:34     ` Ingo Schwarze
2021-03-31 19:33       ` sternenseemann
2021-04-10 15:57       ` [PATCH v2 makewhatis] refactor HOMEBREWDIR into READ_ALLOWED_PATH sternenseemann
2021-04-10 16:15         ` sternenseemann
2021-08-03 16:42           ` sternenseemann
2021-08-05 12:35             ` Ingo Schwarze
2021-08-07  0:29               ` sternenseemann
2021-08-07 13:17                 ` Ingo Schwarze

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8bce7cc9-954e-1c28-ee25-13969f66eb20@systemli.org \
    --to=sternenseemann@systemli.org \
    --cc=tech@mandoc.bsd.lv \
    --subject='Re: [PATCH makewhatis] add NIXSTOREDIR configuration variable to support NixOS' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).