2023-11-23 15:16:41 +01:00
|
|
|
{ writeShellScriptBin, makeDesktopItem, symlinkJoin }:
|
2023-12-09 09:05:16 +01:00
|
|
|
{ html, pathName ? "home-manager", projectName ? pathName
|
|
|
|
, name ? "${pathName}-help" }:
|
2023-11-23 15:16:41 +01:00
|
|
|
let
|
|
|
|
helpScript = writeShellScriptBin name ''
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
if [[ ! -v BROWSER || -z $BROWSER ]]; then
|
|
|
|
for candidate in xdg-open open w3m; do
|
|
|
|
BROWSER="$(type -P $candidate || true)"
|
|
|
|
if [[ -x $BROWSER ]]; then
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -v BROWSER || -z $BROWSER ]]; then
|
|
|
|
echo "$0: unable to start a web browser; please set \$BROWSER"
|
|
|
|
exit 1
|
|
|
|
else
|
2023-12-07 13:36:39 +01:00
|
|
|
exec "$BROWSER" "${html}/share/doc/${pathName}/index.xhtml"
|
2023-11-23 15:16:41 +01:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
|
|
|
desktopItem = makeDesktopItem {
|
|
|
|
name = "${pathName}-manual";
|
|
|
|
desktopName = "${projectName} Manual";
|
|
|
|
genericName = "View ${projectName} documentation in a web browser";
|
|
|
|
icon = "nix-snowflake";
|
|
|
|
exec = "${helpScript}/bin/${name}";
|
|
|
|
categories = [ "System" ];
|
|
|
|
};
|
2023-12-09 09:05:16 +01:00
|
|
|
in symlinkJoin {
|
2023-11-23 15:16:41 +01:00
|
|
|
inherit name;
|
|
|
|
paths = [ helpScript desktopItem ];
|
|
|
|
}
|