2018-09-06 20:17:48 +01:00
|
|
|
# This module optionally starts a browser that shows the NixOS manual
|
|
|
|
# on one of the virtual consoles which is useful for the installation
|
2009-07-14 17:27:46 +01:00
|
|
|
# CD.
|
2009-01-08 23:30:23 +00:00
|
|
|
|
2018-09-06 20:17:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-01-08 23:30:23 +00:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2009-04-14 13:31:08 +01:00
|
|
|
|
2018-09-24 22:00:49 +01:00
|
|
|
let
|
|
|
|
cfg = config.services.nixosManual;
|
|
|
|
cfgd = config.documentation;
|
|
|
|
in
|
2009-04-14 13:31:08 +01:00
|
|
|
|
2009-07-14 17:27:46 +01:00
|
|
|
{
|
2009-04-14 13:31:08 +01:00
|
|
|
|
2009-07-14 17:27:46 +01:00
|
|
|
options = {
|
2009-01-08 23:30:23 +00:00
|
|
|
|
2018-09-06 20:17:48 +01:00
|
|
|
# TODO(@oxij): rename this to `.enable` eventually.
|
2009-07-14 17:27:46 +01:00
|
|
|
services.nixosManual.showManual = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
type = types.bool;
|
2014-03-17 11:45:57 +00:00
|
|
|
default = false;
|
2009-07-14 17:27:46 +01:00
|
|
|
description = ''
|
|
|
|
Whether to show the NixOS manual on one of the virtual
|
|
|
|
consoles.
|
2009-01-08 23:30:23 +00:00
|
|
|
'';
|
2009-07-14 17:27:46 +01:00
|
|
|
};
|
2009-04-14 13:31:08 +01:00
|
|
|
|
2009-07-14 17:27:46 +01:00
|
|
|
services.nixosManual.ttyNumber = mkOption {
|
2016-02-21 20:26:07 +00:00
|
|
|
type = types.int;
|
|
|
|
default = 8;
|
2009-07-14 17:27:46 +01:00
|
|
|
description = ''
|
|
|
|
Virtual console on which to show the manual.
|
|
|
|
'';
|
2009-01-08 23:30:23 +00:00
|
|
|
};
|
2009-04-14 13:31:08 +01:00
|
|
|
|
2009-07-14 17:27:46 +01:00
|
|
|
services.nixosManual.browser = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
type = types.path;
|
2018-05-23 22:55:05 +01:00
|
|
|
default = "${pkgs.w3m-nographics}/bin/w3m";
|
2009-07-14 17:27:46 +01:00
|
|
|
description = ''
|
|
|
|
Browser used to show the manual.
|
|
|
|
'';
|
2009-01-08 23:30:23 +00:00
|
|
|
};
|
2009-04-14 13:31:08 +01:00
|
|
|
|
2009-01-08 23:30:23 +00:00
|
|
|
};
|
2009-07-14 17:27:46 +01:00
|
|
|
|
|
|
|
|
2018-09-25 22:31:43 +01:00
|
|
|
config = mkMerge [
|
|
|
|
(mkIf cfg.showManual {
|
|
|
|
assertions = singleton {
|
|
|
|
assertion = cfgd.enable && cfgd.nixos.enable;
|
|
|
|
message = "Can't enable `services.nixosManual.showManual` without `documentation.nixos.enable`";
|
2009-10-12 17:36:19 +01:00
|
|
|
};
|
2018-09-25 22:31:43 +01:00
|
|
|
})
|
|
|
|
(mkIf (cfg.showManual && cfgd.enable && cfgd.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";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
2009-07-14 17:27:46 +01:00
|
|
|
|
2009-01-08 23:30:23 +00:00
|
|
|
}
|