about summary refs log tree commit diff
path: root/scripts/nix-install-package.in
blob: 0fcfd4e8f77048d20dfcb9d04dc6683167bcc9b4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#! @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 "@bindir@/nix-env -qasf $tmpdir/default.nix";
die if $?;

print "Do you wish to install these (Y/N)? ";
my $reply = <STDIN>;
chomp $reply;
exit if (!($reply eq "y"));

print "Pulling caches...\n";
system "@bindir@/nix-pull `cat $tmpdir/caches`";
die if $?;

print "Installing package...\n";
system "@bindir@/nix-env -if $tmpdir/default.nix '*'";
die if $?;

print "Installation succeeded! Press Enter to continue.\n";
<STDIN>;