Merge pull request #1021 from shlevy/remove-nix-install-package

Remove nix-install-package.
This commit is contained in:
Eelco Dolstra 2016-08-10 14:33:25 +02:00 committed by GitHub
commit fe94b72acc
11 changed files with 2 additions and 410 deletions

1
.gitignore vendored
View file

@ -38,7 +38,6 @@ Makefile.config
/scripts/nix-switch
/scripts/nix-collect-garbage
/scripts/nix-prefetch-url
/scripts/nix-install-package
/scripts/nix-channel
/scripts/nix-build
/scripts/nix-copy-closure

View file

@ -1,208 +0,0 @@
<refentry xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
version="5.0"
xml:id="sec-nix-install-package">
<refmeta>
<refentrytitle>nix-install-package</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="source">Nix</refmiscinfo>
<refmiscinfo class="version"><xi:include href="../version.txt" parse="text"/></refmiscinfo>
</refmeta>
<refnamediv>
<refname>nix-install-package</refname>
<refpurpose>install a Nix Package file</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>nix-install-package</command>
<arg><option>--non-interactive</option></arg>
<arg>
<group choice='req'>
<arg choice='plain'><option>--profile</option></arg>
<arg choice='plain'><option>-p</option></arg>
</group>
<replaceable>path</replaceable>
</arg>
<arg><option>--set</option></arg>
<sbr />
<group choice='req'>
<arg choice='req'>
<option>--url</option>
<arg choice='plain'><replaceable>url</replaceable></arg>
</arg>
<arg choice='req'>
<arg choice='plain'><replaceable>file</replaceable></arg>
</arg>
</group>
</cmdsynopsis>
</refsynopsisdiv>
<refsection><title>Description</title>
<para>The command <command>nix-install-package</command> interactively
installs a Nix Package file (<filename>*.nixpkg</filename>), which is
a small file that contains a store path to be installed along with the
URL of a binary cache. The Nix Package file is either
<replaceable>file</replaceable>, or automatically downloaded from
<replaceable>url</replaceable> if the <option>--url</option> switch is
used.</para>
<para><command>nix-install-package</command> is used in <link
linkend="sec-one-click">one-click installs</link> to download and
install pre-built binary packages with all necessary dependencies.
<command>nix-install-package</command> is intended to be associated
with the MIME type <literal>application/nix-package</literal> in a web
browser so that it is invoked automatically when you click on
<filename>*.nixpkg</filename> files. When invoked, it restarts itself
in a terminal window (since otherwise it would be invisible when run
from a browser), asks the user to confirm whether to install the
package, and if so downloads and installs the package into the users
current profile.</para>
<para>To obtain a window, <command>nix-install-package</command> tries
to restart itself with <command>xterm</command>,
<command>konsole</command> and
<command>gnome-terminal</command>.</para>
</refsection>
<refsection><title>Options</title>
<variablelist>
<varlistentry><term><option>--non-interactive</option></term>
<listitem><para>Do not open a new terminal window and do not ask
for confirmation.</para></listitem>
</varlistentry>
<varlistentry><term><option>--profile</option></term>
<term><option>-p</option></term>
<listitem><para>Install the package into the specified profile
rather than the users current profile.</para></listitem>
</varlistentry>
<varlistentry><term><option>--set</option></term>
<listitem><para>Install the package as the profile so that the
profile contains exactly the contents of the package.</para></listitem>
</varlistentry>
</variablelist>
</refsection>
<refsection><title>Examples</title>
<para>To install <filename>subversion-1.4.0.nixpkg</filename> into the
users current profile, without any prompting:
<screen>
$ nix-install-package --non-interactive subversion-1.4.0.nixpkg</screen>
</para>
<para>To install the same package from some URL into a different
profile:
<screen>
$ nix-install-package --non-interactive -p /nix/var/nix/profiles/eelco \
--url http://nix.cs.uu.nl/dist/nix/nixpkgs-0.10pre6622/pkgs/subversion-1.4.0-i686-linux.nixpkg</screen>
</para>
</refsection>
<refsection><title>Format of <literal>nixpkg</literal> files</title>
<para>A Nix Package file consists of a single line with the following
format:
<screen>
NIXPKG1 <replaceable>manifestURL</replaceable> <replaceable>name</replaceable> <replaceable>system</replaceable> <replaceable>drvPath</replaceable> <replaceable>outPath</replaceable></screen>
The elements are as follows:
<variablelist>
<varlistentry><term><literal>NIXPKG1</literal></term>
<listitem><para>The version of the Nix Package
file.</para></listitem>
</varlistentry>
<varlistentry><term><replaceable>manifestURL</replaceable></term>
<listitem><para>Obsolete.</para></listitem>
</varlistentry>
<varlistentry><term><replaceable>name</replaceable></term>
<listitem><para>The symbolic name and version of the
package.</para></listitem>
</varlistentry>
<varlistentry><term><replaceable>system</replaceable></term>
<listitem><para>The platform identifier of the platform for which
this binary package is intended.</para></listitem>
</varlistentry>
<varlistentry><term><replaceable>drvPath</replaceable></term>
<listitem><para>The path in the Nix store of the derivation from
which <replaceable>outPath</replaceable> was built. Not currently
used.</para></listitem>
</varlistentry>
<varlistentry><term><replaceable>outPath</replaceable></term>
<listitem><para>The path in the Nix store of the
package.</para></listitem>
</varlistentry>
<varlistentry><term><replaceable>binaryCacheURL</replaceable></term>
<listitem><para>The URL of a binary cache containing the closure
of <replaceable>outPath</replaceable>.</para></listitem>
</varlistentry>
</variablelist>
</para>
<para>An example follows:
<screen>
NIXPKG1 http://.../nixpkgs-0.10pre6622/MANIFEST subversion-1.4.0 i686-darwin \
/nix/store/4kh60jkp...-subversion-1.4.0.drv \
/nix/store/nkw7wpgb...-subversion-1.4.0</screen>
(The line breaks (<literal>\</literal>) are for presentation purposes
and not part of the actual file.)
</para>
</refsection>
</refentry>

View file

@ -14,7 +14,6 @@ work with Nix.</para>
<xi:include href="nix-copy-closure.xml" />
<xi:include href="nix-daemon.xml" />
<xi:include href="nix-hash.xml" />
<xi:include href="nix-install-package.xml" />
<xi:include href="nix-instantiate.xml" />
<xi:include href="nix-prefetch-url.xml" />
<xi:include href="nix-push.xml" />

View file

@ -95,18 +95,6 @@ The latter command will upgrade each installed package for which there
is a “newer” version (as determined by comparing the version
numbers).</para></step>
<!--
<step><para>You can also install specific packages directly from
your web browser. For instance, you can go to <link
xlink:href="http://hydra.nixos.org/jobset/nixpkgs/trunk/channel/latest"
/> and click on any link for the individual packages for your
platform. Associate <literal>application/nix-package</literal> with
the program <command>nix-install-package</command>. A window should
appear asking you whether its okay to install the package. Say
<literal>Y</literal>. The package and all its dependencies will be
installed.</para></step>
-->
<step><para>If you're unhappy with the result of a
<command>nix-env</command> action (e.g., an upgraded package turned
out not to work properly), you can go back:

View file

@ -41,7 +41,7 @@ man-pages := $(foreach n, \
nix-env.1 nix-build.1 nix-shell.1 nix-store.1 nix-instantiate.1 \
nix-collect-garbage.1 nix-push.1 \
nix-prefetch-url.1 nix-channel.1 \
nix-install-package.1 nix-hash.1 nix-copy-closure.1 \
nix-hash.1 nix-copy-closure.1 \
nix.conf.5 nix-daemon.8, \
$(d)/$(n))

View file

@ -1,37 +0,0 @@
<chapter xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
version="5.0"
xml:id="sec-one-click">
<title>One-Click Installation</title>
<para>Often, when you want to install a specific package (e.g., from
the <link
xlink:href="http://nixos.org/nixpkgs/">Nix
Packages collection</link>), subscribing to a channel is a bit
cumbersome. And channels dont help you at all if you want to install
an older version of a package than the one provided by the current
contents of the channel, or a package that has been removed from the
channel. Thats when <emphasis>one-click installs</emphasis> come in
handy: you can just go to the web page that contains the package,
click on it, and it will be installed with all the necessary
dependencies.</para>
<para>For instance, you can go to <link
xlink:href="http://hydra.nixos.org/jobset/nixpkgs/trunk/channel/latest"
/> and click on any link for the individual packages for your
platform. The first time you do this, your browser will ask what to
do with <literal>application/nix-package</literal> files. You should
open them with <filename>/nix/bin/nix-install-package</filename>.
This will open a window that asks you to confirm that you want to
install the package. When you answer <literal>Y</literal>, the
package and all its dependencies will be installed. This is a binary
deployment mechanism — you get packages pre-compiled for the selected
platform type.</para>
<para>You can also install <literal>application/nix-package</literal>
files from the command line directly. See <xref
linkend='sec-nix-install-package' /> for details.</para>
</chapter>

View file

@ -18,7 +18,6 @@ who want to <emphasis>create</emphasis> packages should consult
<xi:include href="profiles.xml" />
<xi:include href="garbage-collection.xml" />
<xi:include href="channels.xml" />
<xi:include href="one-click.xml" />
<xi:include href="sharing-packages.xml" />
</part>

View file

@ -2,7 +2,6 @@ nix_bin_scripts := \
$(d)/nix-build \
$(d)/nix-channel \
$(d)/nix-copy-closure \
$(d)/nix-install-package \
$(d)/nix-push
bin-scripts += $(nix_bin_scripts)

View file

@ -1,127 +0,0 @@
#! @perl@ -w @perlFlags@
use utf8;
use strict;
use Nix::Config;
use Nix::Utils;
binmode STDERR, ":encoding(utf8)";
# Parse the command line arguments.
my @args = @ARGV;
my $source;
my $fromURL = 0;
my @extraNixEnvArgs = ();
my $interactive = 1;
my $op = "--install";
while (scalar @args) {
my $arg = shift @args;
if ($arg eq "--help") {
exec "man nix-install-package" or die;
}
elsif ($arg eq "--url") {
$fromURL = 1;
}
elsif ($arg eq "--profile" || $arg eq "-p") {
my $profile = shift @args;
die "$0: --profile requires an argument\n" if !defined $profile;
push @extraNixEnvArgs, "-p", $profile;
}
elsif ($arg eq "--set") {
$op = "--set";
}
elsif ($arg eq "--non-interactive") {
$interactive = 0;
}
else {
$source = $arg;
}
}
die "$0: please specify a .nixpkg file or URL\n" unless defined $source;
# Re-execute in a terminal, if necessary, so that if we're executed
# from a web browser, the user gets to see us.
if ($interactive && !defined $ENV{"NIX_HAVE_TERMINAL"}) {
$ENV{"NIX_HAVE_TERMINAL"} = "1";
$ENV{"LD_LIBRARY_PATH"} = "";
foreach my $term ("xterm", "konsole", "gnome-terminal", "xterm") {
exec($term, "-e", "$Nix::Config::binDir/nix-install-package", @ARGV);
}
die "cannot execute xterm";
}
my $tmpDir = mkTempDir("nix-install-package");
sub barf {
my $msg = shift;
print "\nInstallation failed: $msg\n";
<STDIN> if $interactive;
exit 1;
}
# Download the package description, if necessary.
my $pkgFile = $source;
if ($fromURL) {
$pkgFile = "$tmpDir/tmp.nixpkg";
system("@curl@", "-L", "--silent", $source, "-o", $pkgFile) == 0
or barf "curl failed: $?";
}
# Read and parse the package file.
open PKGFILE, "<$pkgFile" or barf "cannot open $pkgFile: $!";
my $contents = <PKGFILE>;
close PKGFILE;
my $nameRE = "(?: [A-Za-z0-9\+\-\.\_\?\=]+ )"; # see checkStoreName()
my $systemRE = "(?: [A-Za-z0-9\+\-\_]+ )";
my $pathRE = "(?: \/ [\/A-Za-z0-9\+\-\.\_\?\=]* )";
# Note: $pathRE doesn't check that whether we're looking at a valid
# store path. We'll let nix-env do that.
$contents =~
/ ^ \s* (\S+) \s+ (\S+) \s+ ($nameRE) \s+ ($systemRE) \s+ ($pathRE) \s+ ($pathRE) ( \s+ ($Nix::Utils::urlRE) )? /x
or barf "invalid package contents";
my $version = $1;
my $manifestURL = $2;
my $drvName = $3;
my $system = $4;
my $drvPath = $5;
my $outPath = $6;
my $binaryCacheURL = $8;
barf "invalid package version $version" unless $version eq "NIXPKG1";
if ($interactive) {
# Ask confirmation.
print "Do you want to install $drvName (Y/N)? ";
my $reply = <STDIN>;
chomp $reply;
exit if $reply ne "y" && $reply ne "Y";
}
die "$0: package does not supply a binary cache\n" unless defined $binaryCacheURL;
push @extraNixEnvArgs, "--option", "extra-binary-caches", $binaryCacheURL;
print "\nInstalling package...\n";
system("$Nix::Config::binDir/nix-env", $op, $outPath, "--force-name", $drvName, @extraNixEnvArgs) == 0
or barf "nix-env failed: $?";
if ($interactive) {
print "\nInstallation succeeded! Press Enter to continue.\n";
<STDIN>;
}

View file

@ -1,20 +0,0 @@
source common.sh
drvPath=$(nix-instantiate ./dependencies.nix)
outPath=$(nix-store -r $drvPath)
nix-push --dest $cacheDir $outPath
clearStore
clearProfiles
cat > $TEST_ROOT/foo.nixpkg <<EOF
NIXPKG1 - simple $system $drvPath $outPath file://$cacheDir
EOF
nix-install-package --non-interactive -p $profiles/test $TEST_ROOT/foo.nixpkg
test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1
clearProfiles
nix-install-package --non-interactive -p $profiles/test --url file://$TEST_ROOT/foo.nixpkg
test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1

View file

@ -5,7 +5,7 @@ nix_tests = \
init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \
build-hook.sh nix-push.sh gc.sh gc-concurrent.sh \
referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \
gc-runtime.sh install-package.sh check-refs.sh filter-source.sh \
gc-runtime.sh check-refs.sh filter-source.sh \
remote-store.sh export.sh export-graph.sh \
timeout.sh secure-drv-outputs.sh nix-channel.sh \
multiple-outputs.sh import-derivation.sh fetchurl.sh optimise-store.sh \