summary refs log tree commit diff
path: root/nixos/modules/services/misc/nixos-manual.nix
blob: 023a933fd893b25a6b94f2497cb26cf22d621b5b (plain) (blame)
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
69
# This module optionally starts a browser that shows the NixOS manual
# on one of the virtual consoles which is useful for the installation
# CD.

{ config, lib, pkgs, ... }:

with lib;

let cfg = config.services.nixosManual; in

{

  options = {

    # TODO(@oxij): rename this to `.enable` eventually.
    services.nixosManual.showManual = mkOption {
      type = types.bool;
      default = false;
      description = ''
        Whether to show the NixOS manual on one of the virtual
        consoles.
      '';
    };

    services.nixosManual.ttyNumber = mkOption {
      type = types.int;
      default = 8;
      description = ''
        Virtual console on which to show the manual.
      '';
    };

    services.nixosManual.browser = mkOption {
      type = types.path;
      default = "${pkgs.w3m-nographics}/bin/w3m";
      description = ''
        Browser used to show the manual.
      '';
    };

  };


  config = mkIf cfg.showManual {

    assertions = [{
      assertion = config.documentation.nixos.enable;
      message   = "Can't enable `service.nixosManual.showManual` without `documentation.nixos.enable`";
    }];

    boot.extraTTYs = [ "tty${toString cfg.ttyNumber}" ];

    systemd.services."nixos-manual" = {
      description = "NixOS Manual";
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        ExecStart = "${cfg.browser} ${config.system.build.manual.manualHTMLIndex}";
        StandardInput = "tty";
        StandardOutput = "tty";
        TTYPath = "/dev/tty${toString cfg.ttyNumber}";
        TTYReset = true;
        TTYVTDisallocate = true;
        Restart = "always";
      };
    };

  };

}