summary refs log tree commit diff
path: root/upstart-jobs/manual.nix
blob: 5d658ce7681a4ce006f0c7bc7057dcac40e79e9b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{pkgs, config}: 

# Show the NixOS manual on tty7
# Originally used only by installation CD

let
  inherit (pkgs.lib) mkOption;
  options = {
    services = {
      showManual = {
        enable = mkOption {
	  default = false;
	  description = "
	    Whether to show the NixOS manual on the tty7
	  ";
	};
	ttyNumber = mkOption {
	  default = "7";
	  description = "
	    TTY number name to show the manual on
	  ";
	};
	browserPackage = mkOption {
	  default = pkgs.w3m;
	  description = "
	    Package containing the browser to be used
	  ";
	};
	browserCommand = mkOption {
	  default = "bin/w3m";
	  description = "
	    Command (command path is relative to browserPackage) to run the browser
	  ";
	};
	manualFile = mkOption {
	  default = null; 
	  description = "
	    NixOS manual HTML file
	  ";
	};
      };
    };
  };

inherit(pkgs.lib) optional;

inherit (config.services.showManual) enable ttyNumber browserPackage browserCommand 
  manualFile;
	  
realManualFile = if manualFile == null then 
  (import ../doc/manual {nixpkgs = pkgs;})+"/manual.html"
else manualFile;

in

{
  require = [
    options
  ];

  boot = {
    extraTTYs = optional enable ttyNumber;
  };
  
  services = {
    extraJobs = optional enable {
      name = "showManual";

      job = ''
        description "NixOS manual"
	
	start on udev
	stop on shutdown
	respawn ${browserPackage}/${browserCommand} ${realManualFile} < /dev/tty${toString ttyNumber} > /dev/tty${toString ttyNumber} 2>&1
      '';
    };
    ttyBackgrounds = {
      specificThemes = optional enable {
        tty = ttyNumber;
	theme = pkgs.themes "green";
      };
    };
    mingetty = {
      helpLine = if enable then "\nPress <Alt-F${toString ttyNumber}> for NixOS manual." else "";
    };
  };
}