about summary refs log tree commit diff
path: root/machines/sternenseemann/base.nix
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-08-07 17:03:18 +0200
committersternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-08-07 17:03:18 +0200
commit80d32b8eb98276337f8c9ae9ad9b7e2af74e3ae9 (patch)
tree8400acc6e710cb444c7f6fa685f6c561643fb008 /machines/sternenseemann/base.nix
parent9733282fc1a993f91fa7d21070d7a932dff04ba2 (diff)
machines/sterneseemann/base: hack around makewhatis(8) ignoring secs
buildEnv is conservative with creating symlinks, i. e. it only creates
directories if it has to. Consequently if a directory is only present in a
single package in the environment, it'll be a symlink.

Enter: makewhatis(8), a tool that has never imagined a creation as accursed as
Nix or even NixOS. Thus it assumes that probably no one ever uses symlinks in
their man directory and if they do, it'll be to alias man pages. Consequently
it assumes that all symbolic links are files [1] and ignores them in the
normal mode because they are in the wrong place. To still be able to use
apropos(1) with POSIX man pages, introduce this shell hack to re-create the
symlinked directories before building mandoc's db.

[1]: See also
https://inbox.vuxu.org/mandoc-tech/bccac2cd-01b6-b349-86e5-de4066ed8dee@systemli.org/T/#u
Diffstat (limited to 'machines/sternenseemann/base.nix')
-rw-r--r--machines/sternenseemann/base.nix27
1 files changed, 27 insertions, 0 deletions
diff --git a/machines/sternenseemann/base.nix b/machines/sternenseemann/base.nix
index 2ab04672..27da863d 100644
--- a/machines/sternenseemann/base.nix
+++ b/machines/sternenseemann/base.nix
@@ -66,6 +66,33 @@ in {
       manPath = [ "share/man" "share/man/de" ];
     };
 
+    # HACK: create man0p, man1p, man3p etc. as directories in the environment
+    # out path to work around the makewhatis(8) bug that it always assumes
+    # symlinks are files. Since man3p etc. comes from a single package,
+    # buildEnv just symlinks the entire directory and makewhatis(8) then
+    # ignores it.
+    environment.extraSetup = lib.mkBefore ''
+      for dir in $out/share/man/*; do
+        section="$(basename "$dir")"
+        sectionDir="$out/share/man/$section"
+
+        if test -L "$sectionDir"; then
+          dest="$(realpath "$sectionDir")"
+
+          if test -d "$dest"; then
+            echo "Recreating $sectionDir and linking everything from $dest..." 1>&2
+
+            rm "$sectionDir"
+            mkdir "$sectionDir"
+
+            for f in "$dest"/*; do
+              ln -s "$f" -t "$sectionDir"
+            done
+          fi
+        fi
+      done
+    '';
+
     environment.systemPackages = with pkgs; [
       curl wget
       man-pages