1
0
Fork 0
mirror of https://github.com/NotAShelf/neovim-flake.git synced 2024-12-27 01:39:49 +01:00
neovim-flake/docs/html-open-tool.nix

44 lines
1,023 B
Nix
Raw Normal View History

2023-12-09 20:03:58 +01:00
{
writeShellScriptBin,
makeDesktopItem,
symlinkJoin,
}: {
html,
pathName ? "nvf",
2023-12-09 20:03:58 +01:00
projectName ? pathName,
name ? "${pathName}-help",
}: 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
exec "$BROWSER" "${html}/share/doc/${pathName}/index.xhtml"
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"];
};
in
symlinkJoin {
inherit name;
paths = [helpScript desktopItem];
}