2007-02-05 14:10:10 +02:00
|
|
|
<refentry xmlns="http://docbook.org/ns/docbook"
|
2014-08-27 19:41:09 +03:00
|
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
|
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
|
|
|
version="5.0"
|
|
|
|
xml:id="sec-nix-prefetch-url">
|
2005-04-07 18:51:27 +03:00
|
|
|
|
2007-09-19 17:01:41 +03:00
|
|
|
<refmeta>
|
|
|
|
<refentrytitle>nix-prefetch-url</refentrytitle>
|
|
|
|
<manvolnum>1</manvolnum>
|
|
|
|
<refmiscinfo class="source">Nix</refmiscinfo>
|
2014-09-16 15:57:45 +03:00
|
|
|
<refmiscinfo class="version"><xi:include href="../version.txt" parse="text"/></refmiscinfo>
|
2007-09-19 17:01:41 +03:00
|
|
|
</refmeta>
|
|
|
|
|
2005-04-07 18:51:27 +03:00
|
|
|
<refnamediv>
|
|
|
|
<refname>nix-prefetch-url</refname>
|
2011-12-30 15:43:29 +02:00
|
|
|
<refpurpose>copy a file from a URL into the store and print its hash</refpurpose>
|
2005-04-07 18:51:27 +03:00
|
|
|
</refnamediv>
|
|
|
|
|
|
|
|
<refsynopsisdiv>
|
|
|
|
<cmdsynopsis>
|
|
|
|
<command>nix-prefetch-url</command>
|
2012-10-23 19:04:00 +03:00
|
|
|
<arg><option>--type</option> <replaceable>hashAlgo</replaceable></arg>
|
2005-04-07 18:51:27 +03:00
|
|
|
<arg choice='plain'><replaceable>url</replaceable></arg>
|
|
|
|
<arg><replaceable>hash</replaceable></arg>
|
|
|
|
</cmdsynopsis>
|
|
|
|
</refsynopsisdiv>
|
|
|
|
|
|
|
|
|
|
|
|
<refsection><title>Description</title>
|
|
|
|
|
|
|
|
<para>The command <command>nix-prefetch-url</command> downloads the
|
|
|
|
file referenced by the URL <replaceable>url</replaceable>, prints its
|
|
|
|
cryptographic hash, and copies it into the Nix store. The file name
|
|
|
|
in the store is
|
|
|
|
<filename><replaceable>hash</replaceable>-<replaceable>baseName</replaceable></filename>,
|
|
|
|
where <replaceable>baseName</replaceable> is everything following the
|
|
|
|
final slash in <replaceable>url</replaceable>.</para>
|
|
|
|
|
|
|
|
<para>This command is just a convenience for Nix expression writers.
|
|
|
|
Often a Nix expression fetches some source distribution from the
|
|
|
|
network using the <literal>fetchurl</literal> expression contained in
|
|
|
|
Nixpkgs. However, <literal>fetchurl</literal> requires a
|
|
|
|
cryptographic hash. If you don't know the hash, you would have to
|
|
|
|
download the file first, and then <literal>fetchurl</literal> would
|
|
|
|
download it again when you build your Nix expression. Since
|
|
|
|
<literal>fetchurl</literal> uses the same name for the downloaded file
|
|
|
|
as <command>nix-prefetch-url</command>, the redundant download can be
|
|
|
|
avoided.</para>
|
|
|
|
|
|
|
|
<para>If <replaceable>hash</replaceable> is specified, then a download
|
|
|
|
is not performed if the Nix store already contains a file with the
|
|
|
|
same hash and base name. Otherwise, the file is downloaded, and an
|
|
|
|
error if signaled if the actual hash of the file does not match the
|
|
|
|
specified hash.</para>
|
|
|
|
|
|
|
|
<para>This command prints the hash on standard output. Additionally,
|
|
|
|
if the environment variable <envar>PRINT_PATH</envar> is set, the path
|
|
|
|
of the downloaded file in the Nix store is also printed.</para>
|
|
|
|
|
|
|
|
</refsection>
|
|
|
|
|
|
|
|
|
2012-10-23 19:04:00 +03:00
|
|
|
<refsection><title>Options</title>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
|
|
|
|
<varlistentry><term><option>--type</option> <replaceable>hashAlgo</replaceable></term>
|
|
|
|
|
|
|
|
<listitem><para>Use the specified cryptographic hash algorithm,
|
|
|
|
which can be one of <literal>md5</literal>,
|
|
|
|
<literal>sha1</literal>, and
|
|
|
|
<literal>sha256</literal>.</para></listitem>
|
|
|
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
</variablelist>
|
|
|
|
|
|
|
|
</refsection>
|
|
|
|
|
|
|
|
|
2005-04-07 18:51:27 +03:00
|
|
|
<refsection><title>Examples</title>
|
|
|
|
|
|
|
|
<screen>
|
2004-02-10 18:14:47 +02:00
|
|
|
$ nix-prefetch-url ftp://ftp.nluug.nl/pub/gnu/make/make-3.80.tar.bz2
|
2005-04-07 18:51:27 +03:00
|
|
|
0bbd1df101bc0294d440471e50feca71
|
|
|
|
|
|
|
|
$ PRINT_PATH=1 nix-prefetch-url ftp://ftp.nluug.nl/pub/gnu/make/make-3.80.tar.bz2
|
|
|
|
0bbd1df101bc0294d440471e50feca71
|
|
|
|
/nix/store/wvyz8ifdn7wyz1p3pqyn0ra45ka2l492-make-3.80.tar.bz2</screen>
|
|
|
|
|
|
|
|
</refsection>
|
2004-02-10 18:14:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
</refentry>
|