* upstart-jobs/manual.nix:

- Replace "optional" function by one "mkIf".
  - Pretty-print (indentation, extra lines, no trailing-whitespaces).

svn path=/nixos/branches/modular-nixos/; revision=15025
This commit is contained in:
Nicolas Pierron 2009-04-14 12:31:08 +00:00
parent 9741be988c
commit 47b61bdd4a
1 changed files with 75 additions and 56 deletions

View File

@ -1,87 +1,106 @@
{pkgs, config, ...}: {pkgs, config, ...}:
# Show the NixOS manual on tty7 # Show the NixOS manual on tty7
# Originally used only by installation CD # Originally used only by installation CD
let let
inherit (pkgs.lib) mkOption; inherit (pkgs.lib) mkOption;
options = { options = {
services = { services = {
showManual = { showManual = {
enable = mkOption { enable = mkOption {
default = false; default = false;
description = " description = "
Whether to show the NixOS manual on the tty7 Whether to show the NixOS manual on the tty7
"; ";
}; };
ttyNumber = mkOption {
default = "7"; ttyNumber = mkOption {
description = " default = "7";
TTY number name to show the manual on description = "
"; TTY number name to show the manual on
}; ";
browserPackage = mkOption { };
default = pkgs.w3m;
description = " browserPackage = mkOption {
Package containing the browser to be used 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 browserCommand = mkOption {
"; default = "bin/w3m";
}; description = "
manualFile = mkOption { Command (command path is relative to browserPackage) to run the browser
default = null; ";
description = " };
NixOS manual HTML file
"; manualFile = mkOption {
}; default = null;
}; description = "
}; NixOS manual HTML file
";
};
}; # showManual
}; # services
}; };
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 in
{ let
cfg = config.services.showManual;
inherit (cfg) enable ttyNumber browserPackage browserCommand manualFile;
realManualFile =
if manualFile == null then
(import ../doc/manual {nixpkgs = pkgs;})+"/manual.html"
else
manualFile;
inherit (pkgs.lib) mkIf mkThenElse;
in
mkIf enable {
require = [ require = [
options options
]; ];
boot = { boot = {
extraTTYs = optional enable ttyNumber; extraTTYs = [ ttyNumber ];
}; };
services = { services = {
extraJobs = optional enable {
extraJobs = [{
name = "showManual"; name = "showManual";
job = '' job = ''
description "NixOS manual" description "NixOS manual"
start on udev start on udev
stop on shutdown stop on shutdown
respawn ${browserPackage}/${browserCommand} ${realManualFile} < /dev/tty${toString ttyNumber} > /dev/tty${toString ttyNumber} 2>&1 respawn ${browserPackage}/${browserCommand} ${realManualFile} < /dev/tty${toString ttyNumber} > /dev/tty${toString ttyNumber} 2>&1
''; '';
}; }];
ttyBackgrounds = { ttyBackgrounds = {
specificThemes = optional enable { specificThemes = [{
tty = ttyNumber; tty = ttyNumber;
theme = pkgs.themes "green"; theme = pkgs.themes "green";
}];
};
mingetty = {
helpLine = mkThenElse {
thenPart = "\nPress <Alt-F${toString ttyNumber}> for NixOS manual.";
elsePart = "";
}; };
}; };
mingetty = {
helpLine = if enable then "\nPress <Alt-F${toString ttyNumber}> for NixOS manual." else "";
};
}; };
} }