From b1eabe2b1b14b9b46abc5e2a0e530cf3b4dbf15b Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Sun, 22 Feb 2009 16:06:42 +0000 Subject: [PATCH] An upstart job to display manual svn path=/nixos/branches/fix-style/; revision=14158 --- doc/manual/default.nix | 6 +-- system/options.nix | 1 + system/system.nix | 5 ++- upstart-jobs/manual.nix | 87 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 upstart-jobs/manual.nix diff --git a/doc/manual/default.nix b/doc/manual/default.nix index 56657aec2e22..c46e89d0fa14 100644 --- a/doc/manual/default.nix +++ b/doc/manual/default.nix @@ -1,10 +1,10 @@ -{nixpkgsPath ? ../../../nixpkgs, pkgs ? null}: +{nixpkgsPath ? ../../../nixpkgs, nixpkgs ? null}: let - pkgs = if pkgs == null then + pkgs = if nixpkgs == null then import "${nixpkgsPath}/pkgs/top-level/all-packages.nix" {} - else pkgs; + else nixpkgs; options = builtins.toFile "options.xml" (builtins.unsafeDiscardStringContext (builtins.toXML (pkgs.lib.optionAttrSetToDocList "" diff --git a/system/options.nix b/system/options.nix index dfb1019d864a..f8f07bb4b2fc 100644 --- a/system/options.nix +++ b/system/options.nix @@ -2245,6 +2245,7 @@ in (import ../upstart-jobs/cron.nix) (import ../upstart-jobs/fcron.nix) (import ../upstart-jobs/cron/locate.nix) + (import ../upstart-jobs/manual.nix) # fonts (import ../system/fonts.nix) diff --git a/system/system.nix b/system/system.nix index 78b6a0a6deee..bfa81c5566ad 100644 --- a/system/system.nix +++ b/system/system.nix @@ -1,6 +1,7 @@ { platform ? __currentSystem , configuration , nixpkgsPath ? ../../nixpkgs +, nixpkgs ? null }: rec { @@ -24,7 +25,9 @@ rec { pkgs configComponents config; - pkgs = import "${nixpkgsPath}/pkgs/top-level/all-packages.nix" {system = platform;}; + pkgs = if nixpkgs == null then + import "${nixpkgsPath}/pkgs/top-level/all-packages.nix" {system = platform;} + else nixpkgs; manifests = config.installer.manifests; # exported here because nixos-rebuild uses it diff --git a/upstart-jobs/manual.nix b/upstart-jobs/manual.nix new file mode 100644 index 000000000000..5d658ce7681a --- /dev/null +++ b/upstart-jobs/manual.nix @@ -0,0 +1,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 for NixOS manual." else ""; + }; + }; +}