mirror of
https://github.com/NixOS/nix.git
synced 2024-11-26 08:42:30 +00:00
54 lines
1.3 KiB
Plaintext
54 lines
1.3 KiB
Plaintext
#! @perl@ -w
|
|
|
|
use strict;
|
|
use POSIX qw(tmpnam);
|
|
|
|
my $pkgFile = $ARGV[0];
|
|
die unless defined $pkgFile;
|
|
|
|
|
|
# Re-execute in a terminal, if necessary, so that if we're executed
|
|
# from a web browser, the user gets to see us.
|
|
if (!defined $ENV{"NIX_HAVE_TERMINAL"}) {
|
|
$ENV{"NIX_HAVE_TERMINAL"} = "1";
|
|
$ENV{"LD_LIBRARY_PATH"} = "";
|
|
foreach my $term ("konsole", "gnome-terminal", "xterm") {
|
|
exec($term, "-e", "@shell@", "-c", "@bindir@/nix-install-package '$pkgFile' || read");
|
|
}
|
|
die "cannot execute `xterm'";
|
|
}
|
|
|
|
|
|
# Read and parse the package file.
|
|
open PKGFILE, "<$pkgFile" or die "cannot open `$pkgFile': $!";
|
|
my $contents = <PKGFILE>;
|
|
close PKGFILE;
|
|
|
|
$contents =~ /^\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/ or die "invalid package contents";
|
|
my $version = $1;
|
|
my $manifestURL = $2;
|
|
my $drvName = $3;
|
|
my $system = $4;
|
|
my $drvPath = $5;
|
|
my $outPath = $6;
|
|
|
|
die "invalid package version `$version'" unless $version eq "NIXPKG1";
|
|
|
|
|
|
# Ask confirmation.
|
|
print "Do you want to install `$drvName' (Y/N)? ";
|
|
my $reply = <STDIN>;
|
|
chomp $reply;
|
|
exit if $reply ne "y" && $reply ne "Y";
|
|
|
|
print "\nPulling manifests...\n";
|
|
system "@bindir@/nix-pull '$manifestURL'";
|
|
die if $? != 0;
|
|
|
|
print "\nInstalling package...\n";
|
|
system "@bindir@/nix-env -i '$outPath'";
|
|
die if $? != 0;
|
|
|
|
print "\nInstallation succeeded! Press Enter to continue.\n";
|
|
<STDIN>;
|