From 36b90e72d7e09b983acfa08f9016e8b3ece5199d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 19 Feb 2014 17:08:01 +0100 Subject: nix-shell: Add --packages flag This allows you to easily set up a build environment containing the specified packages from Nixpkgs. For example: $ nix-shell -p sqlite xorg.libX11 hello will start a shell in which the given packages are present. --- scripts/nix-build.in | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'scripts/nix-build.in') diff --git a/scripts/nix-build.in b/scripts/nix-build.in index cc6ab423d..452cb901f 100755 --- a/scripts/nix-build.in +++ b/scripts/nix-build.in @@ -12,6 +12,7 @@ my $verbose = 0; my $runEnv = $0 =~ /nix-shell$/; my $pure = 0; my $fromArgs = 0; +my $packages = 0; my @instArgs = (); my @buildArgs = (); @@ -150,6 +151,10 @@ for (my $n = 0; $n < scalar @ARGV; $n++) { push @instArgs, "--expr"; } + elsif ($arg eq "--packages" || $arg eq "-p") { + $packages = 1; + } + elsif (substr($arg, 0, 1) eq "-") { push @buildArgs, $arg; } @@ -159,7 +164,12 @@ for (my $n = 0; $n < scalar @ARGV; $n++) { } } -if (!$fromArgs) { +if ($packages) { + push @instArgs, "--expr"; + @exprs = ( + 'with import { }; runCommand "shell" { buildInputs = [ ' + . (join " ", map { "($_)" } @exprs) . ']; } ""'); +} elsif (!$fromArgs) { @exprs = ("shell.nix") if scalar @exprs == 0 && $runEnv && -e "shell.nix"; @exprs = ("default.nix") if scalar @exprs == 0; } -- cgit v1.2.3