mirror of
https://github.com/nix-community/home-manager.git
synced 2024-12-14 11:57:55 +00:00
613dbb35db
The `nixos-render-docs` tool outputs XHTML formatted content. In order to convince browsers like `firefox` to treat the data as XHTML the extension must be `.xhtml` and not `.html`. Using the XHTML-formatted content as HTML is mainly an issue with self-closing `<a />` tags.
40 lines
1,015 B
Nix
40 lines
1,015 B
Nix
{ writeShellScriptBin, makeDesktopItem, symlinkJoin }:
|
|
{ html
|
|
, pathName ? "home-manager"
|
|
, 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 ];
|
|
}
|