aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/modules/services/misc/nixos-manual.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/modules/services/misc/nixos-manual.nix')
-rw-r--r--nixpkgs/nixos/modules/services/misc/nixos-manual.nix73
1 files changed, 73 insertions, 0 deletions
diff --git a/nixpkgs/nixos/modules/services/misc/nixos-manual.nix b/nixpkgs/nixos/modules/services/misc/nixos-manual.nix
new file mode 100644
index 00000000000..ab73f49d4be
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/misc/nixos-manual.nix
@@ -0,0 +1,73 @@
+# 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;
+ cfgd = config.documentation;
+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 = mkMerge [
+ (mkIf cfg.showManual {
+ assertions = singleton {
+ assertion = cfgd.enable && cfgd.nixos.enable;
+ message = "Can't enable `services.nixosManual.showManual` without `documentation.nixos.enable`";
+ };
+ })
+ (mkIf (cfg.showManual && cfgd.enable && cfgd.nixos.enable) {
+ console.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";
+ };
+ };
+ })
+ ];
+
+}