neovim-flake/docs/html-open-tool.nix

43 lines
935 B
Nix
Raw Permalink Normal View History

2023-12-09 20:03:58 +01:00
{
writeShellScriptBin,
makeDesktopItem,
symlinkJoin,
html,
}: let
helpScript = writeShellScriptBin "nvf-help" ''
2023-12-09 20:03:58 +01:00
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/nvf/index.xhtml"
2023-12-09 20:03:58 +01:00
fi
'';
desktopItem = makeDesktopItem {
name = "nvf-manual";
desktopName = "nvf Manual";
genericName = "View nvf documentation in a web browser";
2023-12-09 20:03:58 +01:00
icon = "nix-snowflake";
exec = "${helpScript}/bin/nvf-help";
2023-12-09 20:03:58 +01:00
categories = ["System"];
};
in
symlinkJoin {
name = "nvf-help";
paths = [
helpScript
desktopItem
];
2023-12-09 20:03:58 +01:00
}