forked from lix-project/lix
* One-click installation :-)
The script nix-install-package takes a `Nix package file' (which contains one or more derivations, along with URLs of Nix caches), unpacks it, pulls the caches, and installs the derivations in the user's environment. For best results, associate the command `xterm -e /nix/bin/nix-install-package' with the MIME type `application/x-nix-package' and visit http://losser.st-lab.cs.uu.nl/~eelco/test/.
This commit is contained in:
parent
b857267893
commit
e7ea52d3b3
|
@ -1,5 +1,6 @@
|
||||||
bin_SCRIPTS = nix-collect-garbage \
|
bin_SCRIPTS = nix-collect-garbage \
|
||||||
nix-pull nix-push nix-prefetch-url
|
nix-pull nix-push nix-prefetch-url \
|
||||||
|
nix-install-package
|
||||||
|
|
||||||
noinst_SCRIPTS = nix-profile.sh
|
noinst_SCRIPTS = nix-profile.sh
|
||||||
|
|
||||||
|
@ -12,8 +13,8 @@ install-exec-local:
|
||||||
|
|
||||||
include ../substitute.mk
|
include ../substitute.mk
|
||||||
|
|
||||||
EXTRA_DIST = nix-switch.in nix-collect-garbage.in \
|
EXTRA_DIST = nix-collect-garbage.in \
|
||||||
nix-pull.in nix-push.in nix-profile.sh.in \
|
nix-pull.in nix-push.in nix-profile.sh.in \
|
||||||
nix-prefetch-url.in \
|
nix-prefetch-url.in nix-install-package.in \
|
||||||
prebuilts.conf
|
prebuilts.conf
|
||||||
|
|
||||||
|
|
37
scripts/nix-install-package.in
Normal file
37
scripts/nix-install-package.in
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#! /usr/bin/perl -w
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use POSIX qw(tmpnam);
|
||||||
|
|
||||||
|
my $pkgfile = $ARGV[0];
|
||||||
|
die unless defined $pkgfile;
|
||||||
|
|
||||||
|
my $tmpdir;
|
||||||
|
do { $tmpdir = tmpnam(); }
|
||||||
|
until mkdir $tmpdir, 0777;
|
||||||
|
|
||||||
|
# !!! remove tmpdir on exit
|
||||||
|
|
||||||
|
print "unpacking $pkgfile in $tmpdir...\n";
|
||||||
|
system "bunzip2 < $pkgfile | (cd $tmpdir && tar xf -)";
|
||||||
|
die if $?;
|
||||||
|
|
||||||
|
print "this package contains the following derivations:\n";
|
||||||
|
system "nix-env -qsf $tmpdir/default.nix";
|
||||||
|
die if $?;
|
||||||
|
|
||||||
|
print "do you wish to install them (y/n)? ";
|
||||||
|
my $reply = <STDIN>;
|
||||||
|
chomp $reply;
|
||||||
|
exit if (!($reply eq "y"));
|
||||||
|
|
||||||
|
print "pulling caches...\n";
|
||||||
|
system "nix-pull `cat $tmpdir/caches`";
|
||||||
|
die if $?;
|
||||||
|
|
||||||
|
print "installing package...\n";
|
||||||
|
system "nix-env -i $tmpdir/default.nix '*'";
|
||||||
|
die if $?;
|
||||||
|
|
||||||
|
print "installing succeeded! (enter to continue)\n";
|
||||||
|
<STDIN>;
|
|
@ -19,15 +19,10 @@ my @sucs;
|
||||||
|
|
||||||
my $fullexpr = "[";
|
my $fullexpr = "[";
|
||||||
|
|
||||||
open CONFFILE, "<$conffile";
|
|
||||||
|
|
||||||
while (<CONFFILE>) {
|
sub processURL {
|
||||||
|
my $url = shift;
|
||||||
chomp;
|
|
||||||
if (/^\s*(\S+)\s*(\#.*)?$/) {
|
|
||||||
my $url = $1;
|
|
||||||
$url =~ s/\/$//;
|
$url =~ s/\/$//;
|
||||||
|
|
||||||
print "obtaining list of Nix archives at $url...\n";
|
print "obtaining list of Nix archives at $url...\n";
|
||||||
|
|
||||||
system "wget --cache=off '$url'/MANIFEST -O '$manifest' 2> /dev/null"; # !!! escape
|
system "wget --cache=off '$url'/MANIFEST -O '$manifest' 2> /dev/null"; # !!! escape
|
||||||
|
@ -60,7 +55,7 @@ while (<CONFFILE>) {
|
||||||
if (/^\}$/) {
|
if (/^\}$/) {
|
||||||
$inside = 0;
|
$inside = 0;
|
||||||
my $fullurl = "$url/$narname";
|
my $fullurl = "$url/$narname";
|
||||||
print "$storepath\n";
|
# print "$storepath\n";
|
||||||
|
|
||||||
# Construct a Nix expression that fetches and unpacks a
|
# Construct a Nix expression that fetches and unpacks a
|
||||||
# Nix archive from the network.
|
# Nix archive from the network.
|
||||||
|
@ -99,6 +94,23 @@ while (<CONFFILE>) {
|
||||||
close MANIFEST;
|
close MANIFEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Obtain URLs either from the command line or from a configuration file.
|
||||||
|
if (scalar @ARGV > 0) {
|
||||||
|
while (@ARGV) {
|
||||||
|
my $url = shift @ARGV;
|
||||||
|
processURL $url;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
open CONFFILE, "<$conffile";
|
||||||
|
while (<CONFFILE>) {
|
||||||
|
chomp;
|
||||||
|
if (/^\s*(\S+)\s*(\#.*)?$/) {
|
||||||
|
my $url = $1;
|
||||||
|
processURL $url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close CONFFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fullexpr .= "]";
|
$fullexpr .= "]";
|
||||||
|
|
Loading…
Reference in a new issue