#! @perl@ -w @perlFlags@ use utf8; use strict; use Nix::Config; use Nix::Store; use Nix::Utils; use File::Basename; 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 @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 $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 && scalar @ARGV == 1) { $script = $ARGV[0]; if (-f $script && -x $script) { open SCRIPT, "<$script" or die "$0: cannot open ‘$script’: $!\n"; my $first =