about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-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
7 files changed, 28 insertions, 83 deletions
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;