2018-09-06 21:17:48 +02: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 18:27:46 +02:00
|
|
|
# CD.
|
2009-01-09 00:30:23 +01:00
|
|
|
|
2018-09-06 21:17:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-01-09 00:30:23 +01:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2009-04-14 14:31:08 +02:00
|
|
|
|
2018-09-24 23:00:49 +02:00
|
|
|
let
|
|
|
|
cfg = config.services.nixosManual;
|
|
|
|
cfgd = config.documentation;
|
|
|
|
in
|
2009-04-14 14:31:08 +02:00
|
|
|
|
2009-07-14 18:27:46 +02:00
|
|
|
{
|
2009-04-14 14:31:08 +02:00
|
|
|
|
2009-07-14 18:27:46 +02:00
|
|
|
options = {
|
2009-01-09 00:30:23 +01:00
|
|
|
|
2018-09-06 21:17:48 +02:00
|
|
|
# TODO(@oxij): rename this to `.enable` eventually.
|
2009-07-14 18:27:46 +02:00
|
|
|
services.nixosManual.showManual = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
type = types.bool;
|
2014-03-17 12:45:57 +01:00
|
|
|
default = false;
|
2009-07-14 18:27:46 +02:00
|
|
|
description = ''
|
|
|
|
Whether to show the NixOS manual on one of the virtual
|
|
|
|
consoles.
|
2009-01-09 00:30:23 +01:00
|
|
|
'';
|
2009-07-14 18:27:46 +02:00
|
|
|
};
|
2009-04-14 14:31:08 +02:00
|
|
|
|
2009-07-14 18:27:46 +02:00
|
|
|
services.nixosManual.ttyNumber = mkOption {
|
2016-02-21 21:26:07 +01:00
|
|
|
type = types.int;
|
|
|
|
default = 8;
|
2009-07-14 18:27:46 +02:00
|
|
|
description = ''
|
|
|
|
Virtual console on which to show the manual.
|
|
|
|
'';
|
2009-01-09 00:30:23 +01:00
|
|
|
};
|
2009-04-14 14:31:08 +02:00
|
|
|
|
2009-07-14 18:27:46 +02:00
|
|
|
services.nixosManual.browser = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
type = types.path;
|
2018-05-23 23:55:05 +02:00
|
|
|
default = "${pkgs.w3m-nographics}/bin/w3m";
|
2009-07-14 18:27:46 +02:00
|
|
|
description = ''
|
|
|
|
Browser used to show the manual.
|
|
|
|
'';
|
2009-01-09 00:30:23 +01:00
|
|
|
};
|
2009-04-14 14:31:08 +02:00
|
|
|
|
2009-01-09 00:30:23 +01:00
|
|
|
};
|
2009-07-14 18:27:46 +02:00
|
|
|
|
|
|
|
|
2018-09-25 23:31:43 +02: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 18:36:19 +02:00
|
|
|
};
|
2018-09-25 23:31:43 +02: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 18:27:46 +02:00
|
|
|
|
2009-01-09 00:30:23 +01:00
|
|
|
}
|