2017-01-15 20:56:18 +01:00
|
|
|
|
{ config, lib, pkgs, baseModules, ... }:
|
|
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
2018-05-18 23:18:12 +02:00
|
|
|
|
cfg = config.manual;
|
|
|
|
|
|
2017-01-15 20:56:18 +01:00
|
|
|
|
/* For the purpose of generating docs, evaluate options with each derivation
|
|
|
|
|
in `pkgs` (recursively) replaced by a fake with path "\${pkgs.attribute.path}".
|
|
|
|
|
It isn't perfect, but it seems to cover a vast majority of use cases.
|
|
|
|
|
Caveat: even if the package is reached by a different means,
|
|
|
|
|
the path above will be shown and not e.g. `${config.services.foo.package}`. */
|
2018-05-07 00:10:58 +02:00
|
|
|
|
homeManagerManual = import ../doc {
|
2017-01-15 20:56:18 +01:00
|
|
|
|
inherit pkgs config;
|
|
|
|
|
version = "0.1";
|
2018-05-11 19:25:06 +02:00
|
|
|
|
revision = "master";
|
2017-01-15 20:56:18 +01:00
|
|
|
|
options =
|
|
|
|
|
let
|
|
|
|
|
scrubbedEval = evalModules {
|
2018-05-06 22:14:50 +02:00
|
|
|
|
modules = [ { nixpkgs.localSystem = config.nixpkgs.localSystem; } ] ++ baseModules;
|
2017-01-15 20:56:18 +01:00
|
|
|
|
args = (config._module.args) // { modules = [ ]; };
|
|
|
|
|
specialArgs = { pkgs = scrubDerivations "pkgs" pkgs; };
|
|
|
|
|
};
|
|
|
|
|
scrubDerivations = namePrefix: pkgSet: mapAttrs
|
|
|
|
|
(name: value:
|
|
|
|
|
let wholeName = "${namePrefix}.${name}"; in
|
|
|
|
|
if isAttrs value then
|
|
|
|
|
scrubDerivations wholeName value
|
|
|
|
|
// (optionalAttrs (isDerivation value) { outPath = "\${${wholeName}}"; })
|
|
|
|
|
else value
|
|
|
|
|
)
|
|
|
|
|
pkgSet;
|
|
|
|
|
in scrubbedEval.options;
|
|
|
|
|
};
|
|
|
|
|
|
2018-05-18 23:18:12 +02:00
|
|
|
|
manualHtmlRoot = "${homeManagerManual.manual}/share/doc/home-manager/index.html";
|
|
|
|
|
|
2019-03-21 00:39:54 +01:00
|
|
|
|
helpScript = pkgs.writeShellScriptBin "home-manager-help" ''
|
2018-05-18 23:18:12 +02:00
|
|
|
|
#!${pkgs.bash}/bin/bash -e
|
|
|
|
|
|
|
|
|
|
if [ -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 [ -z "$BROWSER" ]; then
|
|
|
|
|
echo "$0: unable to start a web browser; please set \$BROWSER"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
exec "$BROWSER" ${manualHtmlRoot}
|
|
|
|
|
'';
|
|
|
|
|
|
2017-01-15 20:56:18 +01:00
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
options = {
|
2018-05-18 23:18:12 +02:00
|
|
|
|
manual.html.enable = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether to install the HTML manual. This also installs the
|
|
|
|
|
<command>home-manager-help</command> tool, which opens a local
|
|
|
|
|
copy of the Home Manager manual in the system web browser.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-15 20:56:18 +01:00
|
|
|
|
manual.manpages.enable = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
example = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether to install the configuration manual page. The manual can
|
|
|
|
|
be reached by <command>man home-configuration.nix</command>.
|
|
|
|
|
</para><para>
|
|
|
|
|
When looking at the manual page pretend that all references to
|
|
|
|
|
NixOS stuff are actually references to Home Manager stuff.
|
|
|
|
|
Thanks!
|
|
|
|
|
'';
|
|
|
|
|
};
|
2019-04-13 09:39:14 +02:00
|
|
|
|
|
|
|
|
|
manual.json.enable = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
|
|
|
|
example = true;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether to install a JSON formatted list of all Home Manager
|
|
|
|
|
options. This can be located at
|
|
|
|
|
<filename><profile directory>/share/doc/home-manager/options.json</filename>,
|
|
|
|
|
and may be used for navigating definitions, auto-completing,
|
|
|
|
|
and other miscellaneous tasks.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2017-01-15 20:56:18 +01:00
|
|
|
|
};
|
|
|
|
|
|
2018-05-18 23:18:12 +02:00
|
|
|
|
config = {
|
|
|
|
|
home.packages = mkMerge [
|
|
|
|
|
(mkIf cfg.html.enable [ helpScript homeManagerManual.manual ])
|
|
|
|
|
(mkIf cfg.manpages.enable [ homeManagerManual.manpages ])
|
2019-04-13 09:39:14 +02:00
|
|
|
|
(mkIf cfg.json.enable [ homeManagerManual.optionsJSON ])
|
2018-05-18 23:18:12 +02:00
|
|
|
|
];
|
2017-01-15 20:56:18 +01:00
|
|
|
|
};
|
2017-07-21 21:10:32 +02:00
|
|
|
|
|
|
|
|
|
# To fix error during manpage build.
|
2017-09-26 23:40:31 +02:00
|
|
|
|
meta = {
|
|
|
|
|
maintainers = [ maintainers.rycee ];
|
2018-05-06 22:14:50 +02:00
|
|
|
|
doc = builtins.toFile "nothingness" "";
|
2017-09-26 23:40:31 +02:00
|
|
|
|
};
|
2017-01-15 20:56:18 +01:00
|
|
|
|
}
|