* nix-install-package: Use the new (trivial) package format generated
by the build farm. See e.g., http://catamaran.labs.cs.uu.nl/dist/nixpkgs-0.8/nixpkgs-0.7pre2302/; the user can click on packages, and they will be installed (assuming the `application/nix-package' MIME type has been associated with `nix-install-package'). Nix expressions are no longer involved: a "package" is just a pointer to a manifest, and the top-level store derivation to be added to the user environment. This makes these packages independent from Nix expression evolution. Note that we install the store derivation ($drvPath), not the resulting output path ($outPath). This is equivalent, except that installing the derivation maintains the back-link from the output path to the derivation that built it. This is useful for maintenance. * Automatically re-exec in an xterm so that the user sees something when `nix-install-package' is run from a browser.
This commit is contained in:
parent
3259ae5811
commit
6bafeafb88
|
@ -3,35 +3,48 @@
|
||||||
use strict;
|
use strict;
|
||||||
use POSIX qw(tmpnam);
|
use POSIX qw(tmpnam);
|
||||||
|
|
||||||
my $pkgfile = $ARGV[0];
|
my $pkgFile = $ARGV[0];
|
||||||
die unless defined $pkgfile;
|
die unless defined $pkgFile;
|
||||||
|
|
||||||
my $tmpdir;
|
|
||||||
do { $tmpdir = tmpnam(); }
|
|
||||||
until mkdir $tmpdir, 0777;
|
|
||||||
|
|
||||||
# !!! remove tmpdir on exit
|
# 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";
|
||||||
|
exec("xterm", "-e", "@bindir@/nix-install-package", "$pkgFile");
|
||||||
|
die "cannot execute `xterm'";
|
||||||
|
}
|
||||||
|
|
||||||
print "Unpacking $pkgfile in $tmpdir...\n";
|
|
||||||
system "bunzip2 < $pkgfile | (cd $tmpdir && tar xf -)";
|
|
||||||
die if $?;
|
|
||||||
|
|
||||||
print "This package contains the following derivations:\n";
|
# Read and parse the package file.
|
||||||
system "@bindir@/nix-env -qasf $tmpdir/default.nix";
|
open PKGFILE, "<$pkgFile" or die "cannot open `$pkgFile': $!";
|
||||||
die if $?;
|
my $contents = <PKGFILE>;
|
||||||
|
close PKGFILE;
|
||||||
|
|
||||||
print "Do you wish to install these (Y/N)? ";
|
$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>;
|
my $reply = <STDIN>;
|
||||||
chomp $reply;
|
chomp $reply;
|
||||||
exit if (!($reply eq "y"));
|
exit if $reply ne "y" && $reply ne "Y";
|
||||||
|
|
||||||
print "Pulling caches...\n";
|
print "\nPulling manifests...\n";
|
||||||
system "@bindir@/nix-pull `cat $tmpdir/caches`";
|
system "@bindir@/nix-pull '$manifestURL'";
|
||||||
die if $?;
|
die if $? != 0;
|
||||||
|
|
||||||
print "Installing package...\n";
|
print "\nInstalling package...\n";
|
||||||
system "@bindir@/nix-env -if $tmpdir/default.nix '*'";
|
system "@bindir@/nix-env -i '$drvPath'";
|
||||||
die if $?;
|
die if $? != 0;
|
||||||
|
|
||||||
print "Installation succeeded! Press Enter to continue.\n";
|
print "\nInstallation succeeded! Press Enter to continue.\n";
|
||||||
<STDIN>;
|
<STDIN>;
|
||||||
|
|
Loading…
Reference in a new issue