2018-09-06 19:17:48 +00: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 16:27:46 +00:00
|
|
|
# CD.
|
2009-01-08 23:30:23 +00:00
|
|
|
|
2018-09-06 19:17:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-01-08 23:30:23 +00:00
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
with lib;
|
2009-04-14 12:31:08 +00:00
|
|
|
|
2018-09-06 19:17:48 +00:00
|
|
|
let cfg = config.services.nixosManual; in
|
2009-04-14 12:31:08 +00:00
|
|
|
|
2009-07-14 16:27:46 +00:00
|
|
|
{
|
2009-04-14 12:31:08 +00:00
|
|
|
|
2009-07-14 16:27:46 +00:00
|
|
|
options = {
|
2009-01-08 23:30:23 +00:00
|
|
|
|
2018-09-06 19:17:48 +00:00
|
|
|
# TODO(@oxij): rename this to `.enable` eventually.
|
2009-07-14 16:27:46 +00: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 16:27:46 +00: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 16:27:46 +00:00
|
|
|
};
|
2009-04-14 12:31:08 +00:00
|
|
|
|
2009-07-14 16:27:46 +00:00
|
|
|
services.nixosManual.ttyNumber = mkOption {
|
2016-02-21 20:26:07 +00:00
|
|
|
type = types.int;
|
|
|
|
default = 8;
|
2009-07-14 16:27:46 +00:00
|
|
|
description = ''
|
|
|
|
Virtual console on which to show the manual.
|
|
|
|
'';
|
2009-01-08 23:30:23 +00:00
|
|
|
};
|
2009-04-14 12:31:08 +00:00
|
|
|
|
2009-07-14 16:27:46 +00:00
|
|
|
services.nixosManual.browser = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
type = types.path;
|
2018-05-23 21:55:05 +00:00
|
|
|
default = "${pkgs.w3m-nographics}/bin/w3m";
|
2009-07-14 16:27:46 +00:00
|
|
|
description = ''
|
|
|
|
Browser used to show the manual.
|
|
|
|
'';
|
2009-01-08 23:30:23 +00:00
|
|
|
};
|
2009-04-14 12:31:08 +00:00
|
|
|
|
2009-01-08 23:30:23 +00:00
|
|
|
};
|
2009-07-14 16:27:46 +00:00
|
|
|
|
|
|
|
|
2018-09-06 19:17:48 +00:00
|
|
|
config = mkIf cfg.showManual {
|
2009-10-05 13:55:33 +00:00
|
|
|
|
2018-09-06 19:17:48 +00:00
|
|
|
assertions = [{
|
|
|
|
assertion = config.documentation.nixos.enable;
|
|
|
|
message = "Can't enable `service.nixosManual.showManual` without `documentation.nixos.enable`";
|
|
|
|
}];
|
2009-07-14 16:27:46 +00:00
|
|
|
|
2018-09-06 19:17:48 +00:00
|
|
|
boot.extraTTYs = [ "tty${toString cfg.ttyNumber}" ];
|
2009-07-14 16:27:46 +00:00
|
|
|
|
2018-09-06 19:17:48 +00:00
|
|
|
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-10-12 16:36:19 +00:00
|
|
|
};
|
2018-09-06 19:17:48 +00:00
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-07-14 16:27:46 +00:00
|
|
|
};
|
|
|
|
|
2009-01-08 23:30:23 +00:00
|
|
|
}
|