1 #!/usr/bin/env nix-shell
2 #!nix-shell -i zsh -p zsh
5 # cd into nixpkgs' root, get the store path of `systemd.man`
6 cd "$(dirname "$0")/../../.."
7 SYSTEMD_MAN_DIR
="$(nix-build -A systemd.man)/share/man"
9 # For each manual section
10 for section
in {1.
.8}; do
11 sec_dir
="${SYSTEMD_MAN_DIR}/man${section}"
13 # skip section 3 (library calls)
14 ! [[ $section -eq 3 ]] ||
continue
16 # for each manpage in that section (potentially none)
17 for manpage
in ${sec_dir}/*(N
); do
18 # strip the directory prefix and (compressed) manpage suffix
19 page
="$(basename "$manpage" ".
${section}.gz
")"
21 # if this is the manpage of a service unit
22 if [[ "$page" =~
".*\.service" ]]; then
23 # ... and a manpage exists without the `.service` suffix
24 potential_alias
="${sec_dir}/${page%\.service}.${section}.gz"
25 ! [[ -e "${potential_alias}" &&
26 # ... which points to the same file, then skip
27 "$(gunzip -c "${potential_alias}")" == ".so ${page}.${section}" ]] || continue
30 # else produce a JSON fragment, with the link to the upstream manpage (as HTML)
31 echo " \"${page}(${section})\": \"https://www.freedesktop.org/software/systemd/man/${page}.html
\","