2009-07-14 16:27:46 +00:00
|
|
|
# This module includes the NixOS man-pages in the system environment,
|
|
|
|
# and optionally starts a browser that shows the NixOS manual on one
|
|
|
|
# of the virtual consoles. The latter is useful for the installation
|
|
|
|
# CD.
|
2009-01-08 23:30:23 +00:00
|
|
|
|
2014-05-05 19:18:53 +00:00
|
|
|
{ config, lib, pkgs, baseModules, ... }:
|
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
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
let
|
2009-01-08 23:30:23 +00:00
|
|
|
|
2009-07-14 16:27:46 +00:00
|
|
|
cfg = config.services.nixosManual;
|
2009-01-08 23:30:23 +00:00
|
|
|
|
2013-10-24 17:58:34 +00:00
|
|
|
versionModule =
|
|
|
|
{ system.nixosVersionSuffix = config.system.nixosVersionSuffix;
|
|
|
|
system.nixosRevision = config.system.nixosRevision;
|
2015-04-08 21:12:11 +00:00
|
|
|
nixpkgs.system = config.nixpkgs.system;
|
2013-10-24 17:58:34 +00:00
|
|
|
};
|
|
|
|
|
2013-10-28 14:48:20 +00:00
|
|
|
eval = evalModules {
|
|
|
|
modules = [ versionModule ] ++ baseModules;
|
2015-03-12 22:19:23 +00:00
|
|
|
args = (config._module.args) // { modules = [ ]; };
|
2013-10-28 14:48:20 +00:00
|
|
|
};
|
|
|
|
|
2009-09-18 15:27:10 +00:00
|
|
|
manual = import ../../../doc/manual {
|
2013-10-17 11:43:40 +00:00
|
|
|
inherit pkgs;
|
2013-11-01 15:44:03 +00:00
|
|
|
version = config.system.nixosVersion;
|
2013-10-24 17:58:34 +00:00
|
|
|
revision = config.system.nixosRevision;
|
2013-10-28 14:48:20 +00:00
|
|
|
options = eval.options;
|
2009-09-18 15:27:10 +00:00
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2014-08-27 09:08:26 +00:00
|
|
|
entry = "${manual.manual}/share/doc/nixos/index.html";
|
2013-01-08 01:13:33 +00:00
|
|
|
|
|
|
|
help = pkgs.writeScriptBin "nixos-help"
|
|
|
|
''
|
|
|
|
#! ${pkgs.stdenv.shell} -e
|
2013-08-20 11:55:39 +00:00
|
|
|
browser="$BROWSER"
|
|
|
|
if [ -z "$browser" ]; then
|
|
|
|
browser="$(type -P xdg-open || true)"
|
|
|
|
if [ -z "$browser" ]; then
|
|
|
|
browser="$(type -P w3m || true)"
|
|
|
|
if [ -z "$browser" ]; then
|
|
|
|
echo "$0: unable to start a web browser; please set \$BROWSER"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2013-01-08 01:13:33 +00:00
|
|
|
fi
|
2013-08-20 11:55:39 +00:00
|
|
|
exec "$browser" ${entry}
|
2013-01-08 01:13:33 +00:00
|
|
|
'';
|
|
|
|
|
2009-07-14 16:27:46 +00:00
|
|
|
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
|
|
|
|
2009-07-14 16:27:46 +00:00
|
|
|
services.nixosManual.enable = mkOption {
|
2012-06-04 14:35:48 +00:00
|
|
|
type = types.bool;
|
2013-10-30 16:37:45 +00:00
|
|
|
default = true;
|
2009-07-14 16:27:46 +00:00
|
|
|
description = ''
|
|
|
|
Whether to build the NixOS manual pages.
|
|
|
|
'';
|
|
|
|
};
|
2009-04-14 12:31:08 +00:00
|
|
|
|
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 {
|
|
|
|
default = "8";
|
|
|
|
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;
|
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
|
|
|
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2009-10-05 13:55:33 +00:00
|
|
|
system.build.manual = manual;
|
|
|
|
|
2015-10-30 13:15:18 +00:00
|
|
|
environment.systemPackages =
|
|
|
|
[ manual.manual help ]
|
|
|
|
++ optional config.programs.man.enable manual.manpages;
|
2009-07-14 16:27:46 +00:00
|
|
|
|
2009-10-15 14:35:10 +00:00
|
|
|
boot.extraTTYs = mkIf cfg.showManual ["tty${cfg.ttyNumber}"];
|
2009-07-14 16:27:46 +00:00
|
|
|
|
2013-01-16 11:33:18 +00:00
|
|
|
systemd.services = optionalAttrs cfg.showManual
|
2012-10-04 20:15:10 +00:00
|
|
|
{ "nixos-manual" =
|
|
|
|
{ description = "NixOS Manual";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig =
|
2013-01-08 01:13:33 +00:00
|
|
|
{ ExecStart = "${cfg.browser} ${entry}";
|
2012-10-04 20:15:10 +00:00
|
|
|
StandardInput = "tty";
|
|
|
|
StandardOutput = "tty";
|
|
|
|
TTYPath = "/dev/tty${cfg.ttyNumber}";
|
|
|
|
TTYReset = true;
|
|
|
|
TTYVTDisallocate = true;
|
|
|
|
Restart = "always";
|
|
|
|
};
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
|
|
|
};
|
2009-07-14 16:27:46 +00:00
|
|
|
|
|
|
|
services.mingetty.helpLine = mkIf cfg.showManual
|
|
|
|
"\nPress <Alt-F${toString cfg.ttyNumber}> for the NixOS manual.";
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2016-02-03 11:16:33 +00:00
|
|
|
services.nixosManual.browser = mkDefault "${pkgs.w3m-nox}/bin/w3m";
|
|
|
|
|
2009-07-14 16:27:46 +00:00
|
|
|
};
|
|
|
|
|
2009-01-08 23:30:23 +00:00
|
|
|
}
|