From 81796c5baf6801718c2e55491baf725bd89c1753 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 8 Jan 2013 02:13:33 +0100 Subject: [PATCH] =?UTF-8?q?Add=20a=20command=20=E2=80=98nixos-help?= =?UTF-8?q?=E2=80=99=20that=20opens=20the=20NixOS=20manual=20in=20a=20brow?= =?UTF-8?q?ser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/services/misc/nixos-manual.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/services/misc/nixos-manual.nix b/modules/services/misc/nixos-manual.nix index 2e98d50b0ce..1a172904c45 100644 --- a/modules/services/misc/nixos-manual.nix +++ b/modules/services/misc/nixos-manual.nix @@ -16,6 +16,17 @@ let inherit pkgs options; }; + entry = "${manual.manual}/share/doc/nixos/manual.html"; + + help = pkgs.writeScriptBin "nixos-help" + '' + #! ${pkgs.stdenv.shell} -e + if ! ''${BROWSER:-w3m} ${entry}; then + echo "$0: unable to start a web browser; please set \$BROWSER or install ‘w3m’" + exit 1 + fi + ''; + in { @@ -69,7 +80,7 @@ in system.build.manual = manual; - environment.systemPackages = [ manual.manpages ]; + environment.systemPackages = [ manual.manpages help ]; boot.extraTTYs = mkIf cfg.showManual ["tty${cfg.ttyNumber}"]; @@ -78,7 +89,7 @@ in { description = "NixOS Manual"; wantedBy = [ "multi-user.target" ]; serviceConfig = - { ExecStart = "${cfg.browser} ${manual.manual}/share/doc/nixos/manual.html"; + { ExecStart = "${cfg.browser} ${entry}"; StandardInput = "tty"; StandardOutput = "tty"; TTYPath = "/dev/tty${cfg.ttyNumber}";