2 import ./make-test-python.nix ({ pkgs, lib, ... }: let
8 machineNames = builtins.map machineSafe manImplementations;
10 makeConfig = useImpl: {
11 # Note: mandoc currently can't index symlinked section directories.
12 # So if a man section comes from one package exclusively (e. g.
13 # 1p from man-pages-posix and 2 from man-pages), it isn't searchable.
14 environment.systemPackages = [
22 nixos.enable = lib.mkForce true;
26 generateCaches = true;
27 } // lib.listToAttrs (builtins.map (impl: {
30 enable = useImpl == impl;
32 }) manImplementations);
36 machineSafe = builtins.replaceStrings [ "-" ] [ "_" ];
39 meta.maintainers = [ lib.maintainers.sternenseemann ];
41 nodes = lib.listToAttrs (builtins.map (i: {
44 }) manImplementations);
50 def match_man_k(page, section, haystack):
52 Check if the man page {page}({section}) occurs in
53 the output of `man -k` given as haystack. Note:
54 This is not super reliable, e. g. it can't deal
55 with man pages that are in multiple sections.
58 for line in haystack.split("\n"):
59 # man -k can look like this:
62 # pagea, pageb (3, 3P) - foo
63 # pagea, pageb, pagec(3) - bar
64 pages = line.split("(")[0]
65 sections = re.search("\\([a-zA-Z1-9, ]+\\)", line)
69 sections = sections.group(0)[1:-1]
71 if page in pages and f'{section}' in sections:
76 '' + lib.concatMapStrings (machine: ''
77 with subtest("Test direct man page lookups in ${machine}"):
79 ${machine}.succeed("man man > /dev/null")
81 ${machine}.succeed("man 3 libunwind > /dev/null")
82 # NixOS configuration man page is installed
83 ${machine}.succeed("man configuration.nix > /dev/null")
85 with subtest("Test generateCaches via man -k in ${machine}"):
87 ("openssl", "ssl", 3),
88 ("unwind", "libunwind", 3),
89 ("user", "useradd", 8),
90 ("user", "userdel", 8),
95 for (keyword, page, section) in expected:
96 matches = ${machine}.succeed(f"man -k {keyword}")
97 if not match_man_k(page, section, matches):
98 raise Exception(f"{page}({section}) missing in matches: {matches}")