aboutsummaryrefslogtreecommitdiff
path: root/modules/manual.nix
blob: ab01c45003ebd8d06f6531be8767a1b269f13efe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{ config, lib, pkgs, ... }:

with lib;

let

  cfg = config.manual;

  docs = import ../doc { inherit lib pkgs; };

in

{
  options = {
    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.
      '';
    };

    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!
      '';
    };

    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>&lt;profile directory&gt;/share/doc/home-manager/options.json</filename>,
        and may be used for navigating definitions, auto-completing,
        and other miscellaneous tasks.
      '';
    };
  };

  config = {
    home.packages = mkMerge [
      (mkIf cfg.html.enable [ docs.manual.html docs.manual.htmlOpenTool ])
      (mkIf cfg.manpages.enable [ docs.manPages ])
      (mkIf cfg.json.enable [ docs.options.json ])
    ];

    # Whether a dependency on nmd should be introduced.
    home.extraBuilderCommands =
      mkIf (cfg.html.enable || cfg.manpages.enable || cfg.json.enable) ''
        mkdir $out/lib
        ln -s ${docs.nmdSrc} $out/lib/nmd
      '';
  };

}