#! @perl@ -w @perlFlags@ use utf8; use strict; use Nix::Config; use Nix::Store; use Nix::Utils; use File::Basename; use Text::ParseWords; use Cwd; binmode STDERR, ":encoding(utf8)"; my $dryRun = 0; my $verbose = 0; my $runEnv = $0 =~ /nix-shell$/; my $pure = 0; my $fromArgs = 0; my $packages = 0; my $interactive = 1; my @instArgs = (); my @buildArgs = (); my @exprs = (); my $shell = $ENV{SHELL} || "/bin/sh"; my $envCommand = ""; # interactive shell my @envExclude = (); my $myName = $runEnv ? "nix-shell" : "nix-build"; my $inShebang = 0; my $script; my @savedArgs; my $tmpDir = mkTempDir($myName); my $outLink = "./result"; my $drvLink = "$tmpDir/derivation"; # Ensure that the $tmpDir is deleted. $SIG{'INT'} = sub { exit 1 }; # Heuristic to see if we're invoked as a shebang script, namely, if we # have a single argument, it's the name of an executable file, and it # starts with "#!". if ($runEnv && defined $ARGV[0] && $ARGV[0] !~ /nix-shell/) { $script = $ARGV[0]; if (-f $script && -x $script) { open SCRIPT, "<$script" or die "$0: cannot open ‘$script’: $!\n"; my $first =