about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-10-03T20·37-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-10-03T20·40-0400
commita562d544d8520a0f113ad1a348e28ea00f27b693 (patch)
tree5e8d7200b8521aa54e2c8846ef7c31fd5dac737e
parent9c41c66c5b877dbb529f6147b28384a57a591895 (diff)
When ‘--help’ is given, just run ‘man’ to show the manual page
I.e. do what git does.  I'm too lazy to keep the builtin help text up
to date :-)

Also add ‘--help’ to various commands that lacked it
(e.g. nix-collect-garbage).
-rw-r--r--.gitignore6
-rwxr-xr-xscripts/nix-build.in26
-rwxr-xr-xscripts/nix-channel.in28
-rwxr-xr-xscripts/nix-collect-garbage.in2
-rwxr-xr-xscripts/nix-copy-closure.in11
-rwxr-xr-xscripts/nix-install-package.in23
-rwxr-xr-xscripts/nix-pull.in4
-rwxr-xr-xscripts/nix-push.in17
-rw-r--r--src/libmain/shared.cc9
-rw-r--r--src/libmain/shared.hh3
-rw-r--r--src/nix-env/Makefile.am7
-rw-r--r--src/nix-env/help.txt77
-rw-r--r--src/nix-env/nix-env.cc3
-rw-r--r--src/nix-hash/Makefile.am7
-rw-r--r--src/nix-hash/help.txt9
-rw-r--r--src/nix-hash/nix-hash.cc3
-rw-r--r--src/nix-instantiate/Makefile.am7
-rw-r--r--src/nix-instantiate/help.txt31
-rw-r--r--src/nix-instantiate/nix-instantiate.cc3
-rw-r--r--src/nix-store/Makefile.am9
-rw-r--r--src/nix-store/help.txt71
-rw-r--r--src/nix-store/nix-store.cc3
-rw-r--r--src/nix-worker/Makefile.am7
-rw-r--r--src/nix-worker/help.txt10
-rw-r--r--src/nix-worker/nix-worker.cc4
25 files changed, 51 insertions, 329 deletions
diff --git a/.gitignore b/.gitignore
index dd8abf2d2254..962dd2f13bd3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -89,15 +89,12 @@ Makefile.in
 
 # /src/nix-env/
 /src/nix-env/nix-env
-/src/nix-env/help.txt.hh
 
 # /src/nix-hash/
 /src/nix-hash/nix-hash
-/src/nix-hash/help.txt.hh
 
 # /src/nix-instantiate/
 /src/nix-instantiate/nix-instantiate
-/src/nix-instantiate/help.txt.hh
 
 # /src/nix-log2xml/
 /src/nix-log2xml/nix-log2xml
@@ -108,15 +105,12 @@ Makefile.in
 
 # /src/nix-setuid-helper/
 /src/nix-setuid-helper/nix-setuid-helper
-/src/nix-setuid-helper/help.txt.hh
 
 # /src/nix-store/
-/src/nix-store/help.txt.hh
 /src/nix-store/nix-store
 
 # /src/nix-worker/
 /src/nix-worker/nix-worker
-/src/nix-worker/help.txt.hh
 
 # /tests/
 /tests/test-tmp
diff --git a/scripts/nix-build.in b/scripts/nix-build.in
index 8973f5fb7316..427bc605b562 100755
--- a/scripts/nix-build.in
+++ b/scripts/nix-build.in
@@ -33,36 +33,14 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
     my $arg = $ARGV[$n];
 
     if ($arg eq "--help") {
-        print STDERR <<EOF;
-Usage: nix-build [OPTION]... [FILE]...
-
-`nix-build' builds the given Nix expressions (which
-default to ./default.nix if none are given).  A symlink called
-`result' is placed in the current directory.
-
-Flags:
-  --add-drv-link: create a symlink `derivation' to the store derivation
-  --drv-link NAME: create symlink NAME instead of `derivation'
-  --no-out-link: do not create the `result' symlink
-  --out-link / -o NAME: create symlink NAME instead of `result'
-  --attr / -A ATTR: select a specific attribute from the Nix expression
-
-  --run-env: build dependencies of the specified derivation, then start a
-      shell with the environment of the derivation
-  --command: command to run with `--run-env'
-  --exclude: regexp specifying dependencies to be excluded by `--run-env'
-
-Any additional flags are passed to `nix-store'.
-EOF
-        exit 0;
-        # '` hack
+        exec "man nix-build" or die;
     }
 
     elsif ($arg eq "--version") {
         print "nix-build (Nix) $Nix::Config::version\n";
         exit 0;
     }
-    
+
     elsif ($arg eq "--add-drv-link") {
         $drvLink = "./derivation";
     }
diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in
index 61ac823eb1f6..7b292ee8cf64 100755
--- a/scripts/nix-channel.in
+++ b/scripts/nix-channel.in
@@ -74,7 +74,7 @@ sub removeChannel {
     writeChannels;
 
     system("$Nix::Config::binDir/nix-env --profile '$profile' -e '$name'") == 0
-        or die "cannot remove channel `$name'";
+        or die "cannot remove channel `$name'\n";
 }
 
 
@@ -125,7 +125,7 @@ sub update {
         my $fullURL = "$url/nixexprs.tar.bz2";
         print STDERR "downloading Nix expressions from `$fullURL'...\n";
         my ($hash, $path) = `PRINT_PATH=1 QUIET=1 $Nix::Config::binDir/nix-prefetch-url '$fullURL'`;
-        die "cannot fetch `$fullURL'" if $? != 0;
+        die "cannot fetch `$fullURL'\n" if $? != 0;
         chomp $path;
 
         # If the URL contains a version number, append it to the name
@@ -153,26 +153,14 @@ sub update {
 }
 
 
-sub usageError {
-    print STDERR <<EOF;
-Usage:
-  nix-channel --add URL [CHANNEL-NAME]
-  nix-channel --remove CHANNEL-NAME
-  nix-channel --list
-  nix-channel --update [CHANNEL-NAME...]
-EOF
-    exit 1;
-}
-
-
-usageError if scalar @ARGV == 0;
+die "$0: argument expected\n" if scalar @ARGV == 0;
 
 
 while (scalar @ARGV) {
     my $arg = shift @ARGV;
 
     if ($arg eq "--add") {
-        usageError if scalar @ARGV < 1 || scalar @ARGV > 2;
+        die "$0: `--add' requires one or two arguments\n" if scalar @ARGV < 1 || scalar @ARGV > 2;
         my $url = shift @ARGV;
         my $name = shift @ARGV;
         unless (defined $name) {
@@ -185,13 +173,13 @@ while (scalar @ARGV) {
     }
 
     if ($arg eq "--remove") {
-        usageError if scalar @ARGV != 1;
+        die "$0: `--remove' requires one argument\n" if scalar @ARGV != 1;
         removeChannel(shift @ARGV);
         last;
     }
 
     if ($arg eq "--list") {
-        usageError if scalar @ARGV != 0;
+        die "$0: `--list' requires one argument\n" if scalar @ARGV != 0;
         readChannels;
         foreach my $name (keys %channels) {
             print "$name $channels{$name}\n";
@@ -205,7 +193,7 @@ while (scalar @ARGV) {
     }
 
     elsif ($arg eq "--help") {
-        usageError;
+        exec "man nix-channel" or die;
     }
 
     elsif ($arg eq "--version") {
@@ -214,6 +202,6 @@ while (scalar @ARGV) {
     }
 
     else {
-        die "unknown argument `$arg'; try `--help'";
+        die "unknown argument `$arg'; try `--help'\n";
     }
 }
diff --git a/scripts/nix-collect-garbage.in b/scripts/nix-collect-garbage.in
index bd186022095c..28b0c749f125 100755
--- a/scripts/nix-collect-garbage.in
+++ b/scripts/nix-collect-garbage.in
@@ -16,6 +16,8 @@ for my $arg (@ARGV) {
         $removeOld = 1;
     } elsif ($arg eq "--dry-run") {
         $dryRun = 1;
+    } elsif ($arg eq "--help") {
+        exec "man nix-collect-garbage" or die;
     } else {
         push @args, $arg;
     }
diff --git a/scripts/nix-copy-closure.in b/scripts/nix-copy-closure.in
index 12a83cff979c..0eb7a4ed0c16 100755
--- a/scripts/nix-copy-closure.in
+++ b/scripts/nix-copy-closure.in
@@ -37,8 +37,11 @@ my @storePaths = ();
 
 while (@ARGV) {
     my $arg = shift @ARGV;
-    
-    if ($arg eq "--sign") {
+
+    if ($arg eq "--help") {
+        exec "man nix-copy-closure" or die;
+    }
+    elsif ($arg eq "--sign") {
         $sign = 1;
     }
     elsif ($arg eq "--gzip") {
@@ -92,7 +95,7 @@ else { # Copy FROM the remote machine.
     my $extraOpts = $includeOutputs ? "--include-outputs" : "";
     my $pid = open(READ,
         "set -f; ssh @sshOpts $sshHost nix-store --query --requisites $extraOpts @storePaths|") or die;
-    
+
     while (<READ>) {
         chomp;
         die "bad: $_" unless /^\//;
@@ -106,7 +109,7 @@ else { # Copy FROM the remote machine.
         print STDERR "copying ", scalar @missing, " missing paths from ‘$sshHost’...\n";
         $compressor = "| $compressor" if $compressor ne "";
         $decompressor = "$decompressor |" if $decompressor ne "";
-	$progressViewer = "$progressViewer |" if $progressViewer ne "";
+        $progressViewer = "$progressViewer |" if $progressViewer ne "";
         unless ($dryRun) {
             my $extraOpts = $sign ? "--sign" : "";
             system("set -f; ssh $sshHost @sshOpts 'nix-store --export $extraOpts @missing $compressor' | $progressViewer $decompressor $Nix::Config::binDir/nix-store --import > /dev/null") == 0
diff --git a/scripts/nix-install-package.in b/scripts/nix-install-package.in
index 6564529385d6..e45337bcc9e5 100755
--- a/scripts/nix-install-package.in
+++ b/scripts/nix-install-package.in
@@ -6,25 +6,8 @@ use Nix::Config;
 use Nix::Utils;
 
 
-sub usageError {
-    print STDERR <<EOF;
-Usage: nix-install-package (FILE | --url URL)
-
-Install a Nix Package (.nixpkg) either directly from FILE or by
-downloading it from URL.
-
-Flags:
-  --profile / -p LINK: install into the specified profile
-  --non-interactive: don't run inside a new terminal
-EOF
-    ; # '
-    exit 1;
-}
-
-
 # Parse the command line arguments.
 my @args = @ARGV;
-usageError if scalar @args == 0;
 
 my $source;
 my $fromURL = 0;
@@ -34,14 +17,14 @@ my $interactive = 1;
 while (scalar @args) {
     my $arg = shift @args;
     if ($arg eq "--help") {
-        usageError;
+        exec "man nix-install-package" or die;
     }
     elsif ($arg eq "--url") {
         $fromURL = 1;
     }
     elsif ($arg eq "--profile" || $arg eq "-p") {
         my $profile = shift @args;
-        usageError if !defined $profile;
+        die "$0: `--profile' requires an argument\n" if !defined $profile;
         push @extraNixEnvArgs, "-p", $profile;
     }
     elsif ($arg eq "--non-interactive") {
@@ -52,7 +35,7 @@ while (scalar @args) {
     }
 }
 
-usageError unless defined $source;
+die "$0: please specify a .nixpkg file or URL\n" unless defined $source;
 
 
 # Re-execute in a terminal, if necessary, so that if we're executed
diff --git a/scripts/nix-pull.in b/scripts/nix-pull.in
index fbd90c2b257d..58dd2cf27eee 100755
--- a/scripts/nix-pull.in
+++ b/scripts/nix-pull.in
@@ -89,7 +89,9 @@ sub processURL {
 
 while (@ARGV) {
     my $url = shift @ARGV;
-    if ($url eq "--skip-wrong-store") {
+    if ($url eq "--help") {
+        exec "man nix-pull" or die;
+    } elsif ($url eq "--skip-wrong-store") {
         # No-op, no longer supported.
     } else {
         processURL $url;
diff --git a/scripts/nix-push.in b/scripts/nix-push.in
index 00d03c3c1f0c..993b94adf064 100755
--- a/scripts/nix-push.in
+++ b/scripts/nix-push.in
@@ -24,22 +24,11 @@ my $writeManifest = 0;
 my $archivesURL;
 my @roots;
 
-sub showSyntax {
-    print STDERR <<EOF
-Usage: nix-push --dest DIR [--manifest] [--url-prefix URL] PATHS...
-
-`nix-push' packs the closure of PATHS into a set of NAR files stored
-in DIR.  Optionally generate a manifest.
-EOF
-    ; # `
-    exit 1;
-}
-
 for (my $n = 0; $n < scalar @ARGV; $n++) {
     my $arg = $ARGV[$n];
 
     if ($arg eq "--help") {
-        showSyntax;
+        exec "man nix-push" or die;
     } elsif ($arg eq "--bzip2") {
         $compressionType = "bzip2";
     } elsif ($arg eq "--force") {
@@ -56,13 +45,13 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
         die "$0: `$arg' requires an argument\n" unless $n < scalar @ARGV;
         $archivesURL = $ARGV[$n];
     } elsif (substr($arg, 0, 1) eq "-") {
-        showSyntax;
+        die "$0: unknown flag `$arg'\n";
     } else {
         push @roots, $arg;
     }
 }
 
-showSyntax if !defined $destDir;
+die "$0: please specify a destination directory\n" if !defined $destDir;
 
 $archivesURL = "file://$destDir" unless defined $archivesURL;
 
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index 5f92c3df34a0..f8149fc608fd 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -91,6 +91,7 @@ string getArg(const string & opt,
     return *i;
 }
 
+
 /* Initialize and reorder arguments, then call the actual argument
    processor. */
 static void initAndRun(int argc, char * * argv)
@@ -275,6 +276,14 @@ static void * oomHandler(size_t requested)
 }
 
 
+void showManPage(const string & name)
+{
+    string cmd = "man " + name;
+    if (system(cmd.c_str()) != 0)
+        throw Error(format("command `%1%' failed") % cmd);
+}
+
+
 int exitCode = 0;
 char * * argvSaved = 0;
 
diff --git a/src/libmain/shared.hh b/src/libmain/shared.hh
index c69879a12356..9e5ec8360952 100644
--- a/src/libmain/shared.hh
+++ b/src/libmain/shared.hh
@@ -41,6 +41,9 @@ template<class N> N getIntArg(const string & opt,
     return n;
 }
 
+/* Show the manual page for the specified program. */
+void showManPage(const string & name);
+
 /* Whether we're running setuid. */
 extern bool setuidMode;
 
diff --git a/src/nix-env/Makefile.am b/src/nix-env/Makefile.am
index 113baabc41cd..4d3bd111d719 100644
--- a/src/nix-env/Makefile.am
+++ b/src/nix-env/Makefile.am
@@ -1,16 +1,11 @@
 bin_PROGRAMS = nix-env
 
-nix_env_SOURCES = nix-env.cc profiles.cc profiles.hh user-env.cc user-env.hh help.txt
+nix_env_SOURCES = nix-env.cc profiles.cc profiles.hh user-env.cc user-env.hh
 
 nix_env_LDADD = ../libmain/libmain.la ../libexpr/libexpr.la \
  ../libstore/libstore.la ../libutil/libutil.la \
  ../boost/format/libformat.la
 
-nix-env.o: help.txt.hh
-
-%.txt.hh: %.txt
-	../bin2c/bin2c helpText < $< > $@ || (rm $@ && exit 1)
-
 AM_CXXFLAGS = \
  -I$(srcdir)/.. \
  -I$(srcdir)/../libutil -I$(srcdir)/../libstore \
diff --git a/src/nix-env/help.txt b/src/nix-env/help.txt
deleted file mode 100644
index 0ebdca9b22a5..000000000000
--- a/src/nix-env/help.txt
+++ /dev/null
@@ -1,77 +0,0 @@
-Usage: nix-env [OPTIONS...] [ARGUMENTS...]
-
-`nix-env' is a tool to manipulate Nix user environments.
-
-Operations:
-
-  --install / -i: add derivations to the user environment
-  --upgrade / -u: upgrade derivation in the user environment
-  --set: create a user environment containing a single derivation
-  --uninstall / -e: remove derivations from the user environment
-  --query / -q: perform a query on an environment or Nix expression
-  --set-flag NAME VALUE: set derivation meta-attribute to given value
-
-The previous operations take a list of derivation names.  The special
-name `*' may be used to indicate all derivations.
-
-  --switch-profile / -S [FILE]: switch to specified profile
-  --switch-generation / -G NUMBER: switch to specified generation of profile
-  --rollback: switch to the previous generation
-  --list-generations: list available generations of a profile
-  --delete-generations GENERATIONS...: deleted listed generations,
-      `old' for all non-current generations
-  
-  --version: output version information
-  --help: display help
-
-Install / upgrade / uninstall flags:
-
-  --dry-run: show what would be done, but don't do it
-
-Installation sources:
-
-  --from-expression / -E EXPR...: evaluate expressions specified on
-      the command line; expressions should be functions that take the
-      default Nix expression as an argument
-  --from-profile PROFILE NAMES...: copy named packages from PROFILE
-  --attr / -A ATTRS...: select attributes by name from the default Nix
-      expression
-
-Upgrade flags:
-
-  --lt: upgrade if the current version is older (default)
-  --leq: upgrade if the current version is older or equal
-  --eq: "upgrade" if the current version is equal
-  --always: upgrade regardless of current version
-
-Query sources:
-
-  --installed: use installed derivations (default)
-  --available / -a: use derivations available in Nix expression
-
-Query flags:
-
-  --xml: show output in XML format
-  --status / -s: print installed/present status
-  --no-name: hide derivation names
-  --attr-path / -P: shows the unambiguous attribute name of the
-      derivation which can be used when installing with -A
-  --system: print the platform type of the derivation 
-  --compare-versions / -c: compare version to available or installed
-  --drv-path: print path of derivation
-  --out-path: print path of derivation output
-  --description: print description
-  --meta: print all meta attributes (only with --xml)
-
-Options:
-
-  --profile / -p LINK: use specified profile instead of target of ~/.nix-profile
-  --file / -f FILE: use Nix expression FILE for installation, etc.
-  --verbose / -v: verbose operation (may be repeated)
-  --keep-failed / -K: keep temporary directories of failed builds
-  --keep-going / -k: build as many dependencies as possible, even if
-      some dependencies fail to build
-  --preserve-installed: do not replace currently installed versions in `-i'
-  --system-filter SYSTEM: only use derivations for specified platform
-  --prebuilt-only / -b: only use derivations whose prebuilt binaries are
-      available on this machine or are downloadable
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index d9b48e81c9fd..bb6df32d0fd0 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -4,7 +4,6 @@
 #include "misc.hh"
 #include "shared.hh"
 #include "eval.hh"
-#include "help.txt.hh"
 #include "get-drvs.hh"
 #include "attr-path.hh"
 #include "common-opts.hh"
@@ -66,7 +65,7 @@ typedef void (* Operation) (Globals & globals,
 
 void printHelp()
 {
-    cout << string((char *) helpText);
+    showManPage("nix-env");
 }
 
 
diff --git a/src/nix-hash/Makefile.am b/src/nix-hash/Makefile.am
index a4fdb324629d..ef7bb8423980 100644
--- a/src/nix-hash/Makefile.am
+++ b/src/nix-hash/Makefile.am
@@ -1,13 +1,8 @@
 bin_PROGRAMS = nix-hash
 
-nix_hash_SOURCES = nix-hash.cc help.txt
+nix_hash_SOURCES = nix-hash.cc
 nix_hash_LDADD = ../libmain/libmain.la ../libstore/libstore.la ../libutil/libutil.la \
  ../boost/format/libformat.la
 
-nix-hash.o: help.txt.hh
-
-%.txt.hh: %.txt
-	../bin2c/bin2c helpText < $< > $@ || (rm $@ && exit 1)
-
 AM_CXXFLAGS = \
  -I$(srcdir)/.. -I$(srcdir)/../libutil -I$(srcdir)/../libstore -I$(srcdir)/../libmain
diff --git a/src/nix-hash/help.txt b/src/nix-hash/help.txt
deleted file mode 100644
index 6c166f4995d8..000000000000
--- a/src/nix-hash/help.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-Usage: nix-hash [OPTIONS...] [FILES...]
-
-`nix-hash' computes and prints cryptographic hashes for the specified
-files.
-
-  --flat: compute hash of regular file contents, not metadata
-  --base32: print hash in base-32 instead of hexadecimal
-  --type HASH: use hash algorithm HASH ("md5" (default), "sha1", "sha256")
-  --truncate: truncate the hash to 160 bits
diff --git a/src/nix-hash/nix-hash.cc b/src/nix-hash/nix-hash.cc
index 5b35ccd9dae3..af3dda4ad7b8 100644
--- a/src/nix-hash/nix-hash.cc
+++ b/src/nix-hash/nix-hash.cc
@@ -1,6 +1,5 @@
 #include "hash.hh"
 #include "shared.hh"
-#include "help.txt.hh"
 
 #include <iostream>
 
@@ -10,7 +9,7 @@ using namespace nix;
 
 void printHelp()
 {
-    std::cout << string((char *) helpText);
+    showManPage("nix-hash");
 }
 
 
diff --git a/src/nix-instantiate/Makefile.am b/src/nix-instantiate/Makefile.am
index b48dbd9d410f..96978f36c5ae 100644
--- a/src/nix-instantiate/Makefile.am
+++ b/src/nix-instantiate/Makefile.am
@@ -1,15 +1,10 @@
 bin_PROGRAMS = nix-instantiate
 
-nix_instantiate_SOURCES = nix-instantiate.cc help.txt
+nix_instantiate_SOURCES = nix-instantiate.cc
 nix_instantiate_LDADD = ../libmain/libmain.la ../libexpr/libexpr.la \
  ../libstore/libstore.la ../libutil/libutil.la \
  ../boost/format/libformat.la
 
-nix-instantiate.o: help.txt.hh
-
-%.txt.hh: %.txt
-	../bin2c/bin2c helpText < $< > $@ || (rm $@ && exit 1)
-
 AM_CXXFLAGS = \
  -I$(srcdir)/.. -I$(srcdir)/../libutil -I$(srcdir)/../libstore \
  -I$(srcdir)/../libexpr -I$(srcdir)/../libmain -I../libexpr
diff --git a/src/nix-instantiate/help.txt b/src/nix-instantiate/help.txt
deleted file mode 100644
index 21822132aece..000000000000
--- a/src/nix-instantiate/help.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-Usage: nix-instantiate [OPTIONS...] [FILES...]
-
-`nix-instantiate' turns Nix expressions into store derivations. 
-
-The argument `-' may be specified to read a Nix expression from
-standard input.
-
-Options:
-
-  --version: output version information
-  --help: display help
-
-  --verbose / -v: verbose operation (may be repeated)
-
-  --eval-only: evaluate and print resulting term; do not instantiate
-  --parse-only: parse and print abstract syntax tree
-
-  --attr / -A PATH: select an attribute from the top-level expression
-
-  --add-root: add garbage collector roots for the result
-
-For --eval-only / --parse-only:
-
-  --xml: print an XML representation of the abstract syntax tree
-  --no-location: don't provide source location information in the
-    output XML tree
-
-For --eval-only:
-
-  --strict: compute attributes and list elements, rather than being
-    lazy
diff --git a/src/nix-instantiate/nix-instantiate.cc b/src/nix-instantiate/nix-instantiate.cc
index 34f81b14a286..4d8f43507ca7 100644
--- a/src/nix-instantiate/nix-instantiate.cc
+++ b/src/nix-instantiate/nix-instantiate.cc
@@ -8,7 +8,6 @@
 #include "util.hh"
 #include "store-api.hh"
 #include "common-opts.hh"
-#include "help.txt.hh"
 
 #include <map>
 #include <iostream>
@@ -19,7 +18,7 @@ using namespace nix;
 
 void printHelp()
 {
-    std::cout << string((char *) helpText);
+    showManPage("nix-instantiate");
 }
 
 
diff --git a/src/nix-store/Makefile.am b/src/nix-store/Makefile.am
index ef8d760d6f5d..fca9eff7cde8 100644
--- a/src/nix-store/Makefile.am
+++ b/src/nix-store/Makefile.am
@@ -1,17 +1,12 @@
 bin_PROGRAMS = nix-store
 
-nix_store_SOURCES =				\
-  nix-store.cc dotgraph.cc dotgraph.hh help.txt	\
+nix_store_SOURCES =			\
+  nix-store.cc dotgraph.cc dotgraph.hh	\
   xmlgraph.cc xmlgraph.hh
 
 nix_store_LDADD = ../libmain/libmain.la ../libstore/libstore.la ../libutil/libutil.la \
  ../boost/format/libformat.la -lbz2
 
-nix-store.o: help.txt.hh
-
-%.txt.hh: %.txt
-	../bin2c/bin2c helpText < $< > $@ || (rm $@ && exit 1)
-
 AM_CXXFLAGS = \
  -I$(srcdir)/.. -I$(srcdir)/../libutil \
  -I$(srcdir)/../libstore -I$(srcdir)/../libmain
diff --git a/src/nix-store/help.txt b/src/nix-store/help.txt
deleted file mode 100644
index ed4a29a67e17..000000000000
--- a/src/nix-store/help.txt
+++ /dev/null
@@ -1,71 +0,0 @@
-Usage: nix-store [OPTIONS...] [ARGUMENTS...]
-
-`nix-store' is a tool to manipulate the Nix store.
-
-Operations:
-
-  --realise / -r: ensure path validity; if a derivation, ensure the
-      validity of the outputs
-  --add / -A: copy a path to the Nix store
-  --delete: safely delete paths from the Nix store
-  --query / -q: query information
-  --read-log / -l: print build log of given store paths
-
-  --register-validity: register path validity (dangerous!)
-  --check-validity: check path validity
-
-  --gc: run the garbage collector
-
-  --dump: dump a path as a Nix archive (NAR), forgetting dependencies
-  --restore: restore a path from a Nix archive, without
-      registering validity
-
-  --export: export a path as a Nix archive, marking dependencies
-  --import: import a path from a Nix archive, and register as 
-      valid
-
-  --verify: verify Nix structures
-  --verify-path: verify whether the given store paths haven't been modified
-  --optimise: optimise the Nix store by hard-linking identical files
-
-  --query-failed-paths: list paths that failed to build (if enabled)
-  --clear-failed-paths: clear the failed status of the given paths
-
-  --version: output version information
-  --help: display help
-
-Query flags:
-
-  --outputs: query the output paths of a Nix derivation (default)
-  --requisites / -R: print all paths necessary to realise the path
-  --references: print all paths referenced by the path
-  --referrers: print all paths directly refering to the path
-  --referrers-closure: print all paths (in)directly refering to the path
-  --tree: print a tree showing the dependency graph of the path
-  --graph: print a dot graph rooted at given path
-  --xml: emit an XML representation of the graph rooted at the given path
-  --hash: print the SHA-256 hash of the contents of the path
-  --size: print the size of the NAR dump of the path
-  --roots: print the garbage collector roots that point to the path
-
-Query switches (not applicable to all queries):
-
-  --use-output: perform query on output of derivation, not derivation itself
-  --force-realise: realise the path before performing the query
-  --include-outputs: in `-R' on a derivation, include requisites of outputs
-
-Garbage collector options:
-
-  --print-roots: print GC roots and exit
-  --print-live: print live paths and exit
-  --print-dead: print dead paths and exit
-  --delete: delete dead paths (default)
-    
-Options:
-
-  --verbose / -v: verbose operation (may be repeated)
-  --keep-failed / -K: keep temporary directories of failed builds
-  --keep-going / -k: build as many dependencies as possible, even if
-      some dependencies fail to build
-
-  --add-root: add garbage collector roots for the result
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 104e0b241c49..902a2296786f 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -6,7 +6,6 @@
 #include "xmlgraph.hh"
 #include "local-store.hh"
 #include "util.hh"
-#include "help.txt.hh"
 
 #include <iostream>
 #include <algorithm>
@@ -29,7 +28,7 @@ typedef void (* Operation) (Strings opFlags, Strings opArgs);
 
 void printHelp()
 {
-    cout << string((char *) helpText);
+    showManPage("nix-store");
 }
 
 
diff --git a/src/nix-worker/Makefile.am b/src/nix-worker/Makefile.am
index b6094a2a038c..6b1b2827cbf7 100644
--- a/src/nix-worker/Makefile.am
+++ b/src/nix-worker/Makefile.am
@@ -1,14 +1,9 @@
 bin_PROGRAMS = nix-worker
 
-nix_worker_SOURCES = nix-worker.cc help.txt
+nix_worker_SOURCES = nix-worker.cc
 nix_worker_LDADD = ../libmain/libmain.la ../libstore/libstore.la ../libutil/libutil.la \
  ../boost/format/libformat.la
 
-nix-worker.o: help.txt.hh
-
-%.txt.hh: %.txt
-	../bin2c/bin2c helpText < $< > $@ || (rm $@ && exit 1)
-
 AM_CXXFLAGS = \
  -I$(srcdir)/.. -I$(srcdir)/../libutil \
  -I$(srcdir)/../libstore -I$(srcdir)/../libmain
diff --git a/src/nix-worker/help.txt b/src/nix-worker/help.txt
deleted file mode 100644
index b4583cb7e495..000000000000
--- a/src/nix-worker/help.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-Usage: nix-worker [OPTIONS...] [--daemon | --slave]
-
-`nix-worker' is a helper program used to implement secure, multi-user
-Nix stores.  In `--daemon' mode, it goes into the background and waits
-for incoming connections on a Unix domain socket, and forks a process
-for each connection to perform the Nix store operations requested by
-the caller.  In `--slave' mode, `nix-worker' is called directly, and
-the caller and the worker communicate with each other over
-stdin/stdout.  In this mode, the `nix-worker' program should have
-appropriate setuid privileges.
diff --git a/src/nix-worker/nix-worker.cc b/src/nix-worker/nix-worker.cc
index dadde9cc5183..17ffdb616c65 100644
--- a/src/nix-worker/nix-worker.cc
+++ b/src/nix-worker/nix-worker.cc
@@ -923,11 +923,9 @@ void run(Strings args)
 }
 
 
-#include "help.txt.hh"
-
 void printHelp()
 {
-    std::cout << string((char *) helpText);
+    showManPage("nix-worker");
 }