From da996583eef58371854e0c50f0bba3899e4441be Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 14 Jul 2009 16:27:46 +0000 Subject: [PATCH] * Include the NixOS manpages in the system environment. Actually there is only one currently: configuration.nix(5), which contains a list of all the options. svn path=/nixos/branches/modular-nixos/; revision=16360 --- doc/manual/default.nix | 1 + .../installer/cd-dvd/installation-cd-base.nix | 2 +- modules/services/misc/nixos-manual.nix | 166 ++++++++---------- 3 files changed, 77 insertions(+), 92 deletions(-) diff --git a/doc/manual/default.nix b/doc/manual/default.nix index 1909c8a9e44e..271a6a54bcc0 100644 --- a/doc/manual/default.nix +++ b/doc/manual/default.nix @@ -4,6 +4,7 @@ let manualConfig = { environment.checkConfigurationOptions = false; + services.nixosManual.enable = false; }; options = builtins.toFile "options.xml" (builtins.unsafeDiscardStringContext diff --git a/modules/installer/cd-dvd/installation-cd-base.nix b/modules/installer/cd-dvd/installation-cd-base.nix index b45a5cdb6e0e..dc84fa3e8cba 100644 --- a/modules/installer/cd-dvd/installation-cd-base.nix +++ b/modules/installer/cd-dvd/installation-cd-base.nix @@ -83,7 +83,7 @@ in boot.kernelPackages = pkgs.kernelPackages_2_6_29; # Show the manual. - services.showManual.enable = true; + services.nixosManual.showManual = true; # Let the user play Rogue on TTY 8 during the installation. services.rogue.enable = true; diff --git a/modules/services/misc/nixos-manual.nix b/modules/services/misc/nixos-manual.nix index 29df0e3354ae..a886814d76d1 100644 --- a/modules/services/misc/nixos-manual.nix +++ b/modules/services/misc/nixos-manual.nix @@ -1,104 +1,88 @@ +# 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. + {pkgs, config, ...}: -# Show the NixOS manual on tty8 -# Originally used only by installation CD - let - inherit (pkgs.lib) mkOption; + + inherit (pkgs.lib) mkOption mkIf; + + cfg = config.services.nixosManual; + + manual = + # We could speed up the evaluation of the manual expression by + # providing it the optionDeclarations of the current + # configuration. + import ../../../doc/manual {inherit pkgs;}; + +in + +{ options = { - services = { - showManual = { - - enable = mkOption { - default = false; - description = " - Whether to show the NixOS manual on one of the virtual - consoles. - "; - }; - - ttyNumber = mkOption { - default = "8"; - description = " - Virtual console on which to show the manual. - "; - }; - - browser = mkOption { - default = "${pkgs.w3m}/bin/w3m"; - description = '' - Browser used to show the manual. - ''; - }; - - manualFile = mkOption { - # Note: we can't use a default here (see below), since it - # causes an infinite recursion building the manual. - default = null; - description = " - NixOS manual HTML file - "; - }; - - }; # showManual - - }; # services - }; -in - -let - inherit (config.services.showManual) enable ttyNumber browser manualFile; - - realManualFile = - if manualFile == null then - # We could speed up the evaluation of the manual expression by - # providing it the optionDeclarations of the current - # configuration. - "${import ../../../doc/manual {inherit pkgs;}}/manual.html" - else - manualFile; - - inherit (pkgs.lib) mkIf mkThenElse; -in - -mkIf enable { - require = [ - options - ]; - - boot = { - extraTTYs = [ ttyNumber ]; - }; - - services = { - - extraJobs = [{ - name = "nixos-manual"; - - job = '' - description "NixOS manual" - - start on udev - stop on shutdown - respawn ${browser} ${realManualFile} < /dev/tty${toString ttyNumber} > /dev/tty${toString ttyNumber} 2>&1 + services.nixosManual.enable = mkOption { + default = true; + description = '' + Whether to build the NixOS manual pages. ''; - }]; - - ttyBackgrounds = { - specificThemes = [{ - tty = ttyNumber; - theme = pkgs.themes "green"; - }]; }; - mingetty = { - helpLine = mkThenElse { - thenPart = "\nPress for the NixOS manual."; - elsePart = ""; - }; + services.nixosManual.showManual = mkOption { + default = false; + description = '' + Whether to show the NixOS manual on one of the virtual + consoles. + ''; + }; + + services.nixosManual.ttyNumber = mkOption { + default = "8"; + description = '' + Virtual console on which to show the manual. + ''; + }; + + services.nixosManual.browser = mkOption { + default = "${pkgs.w3m}/bin/w3m"; + description = '' + Browser used to show the manual. + ''; }; }; + + + config = mkIf cfg.enable { + + environment.systemPackages = [manual]; + + boot.extraTTYs = mkIf cfg.showManual [cfg.ttyNumber]; + + services.extraJobs = mkIf cfg.showManual (pkgs.lib.singleton + { name = "nixos-manual"; + + job = '' + description "NixOS manual" + + start on udev + stop on shutdown + respawn ${cfg.browser} ${manual}/share/doc/nixos/manual.html \ + < /dev/tty${toString cfg.ttyNumber} > /dev/tty${toString cfg.ttyNumber} 2>&1 + ''; + }); + + services.ttyBackgrounds.specificThemes = mkIf cfg.showManual + [ { tty = cfg.ttyNumber; + theme = pkgs.themes "green"; + } + ]; + + services.mingetty.helpLine = mkIf cfg.showManual + "\nPress for the NixOS manual."; + + }; + }