summary refs log tree commit diff
path: root/doc/manual/nix-push.xml
blob: f439af563d1afe5b9179e0d1cd082e1da82370f4 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<refentry xmlns="http://docbook.org/ns/docbook"
          xmlns:xlink="http://www.w3.org/1999/xlink"
          xmlns:xi="http://www.w3.org/2001/XInclude">

<refmeta>
  <refentrytitle>nix-push</refentrytitle>
  <manvolnum>1</manvolnum>
  <refmiscinfo class="source">Nix</refmiscinfo>
  <refmiscinfo class="version"><xi:include href="version.txt" parse="text"/></refmiscinfo>
</refmeta>

<refnamediv>
  <refname>nix-push</refname>
  <refpurpose>push store paths onto a network cache</refpurpose>
</refnamediv>

<refsynopsisdiv>
  <cmdsynopsis>
    <command>nix-push</command>
    <group choice='req'>
      <arg choice='req'>
        <arg choice='plain'><replaceable>archivesPutURL</replaceable></arg>
        <arg choice='plain'><replaceable>archivesGetURL</replaceable></arg>
        <arg choice='plain'><replaceable>manifestPutURL</replaceable></arg>
      </arg>
      <arg choice='req'>
        <arg choice='plain'><option>--copy</option></arg>
        <arg choice='plain'><replaceable>archivesDir</replaceable></arg>
        <arg choice='plain'><replaceable>manifestFile</replaceable></arg>
      </arg>
    </group>
    <arg choice='plain' rep='repeat'><replaceable>paths</replaceable></arg>
  </cmdsynopsis>
</refsynopsisdiv>


<refsection><title>Description</title>

<para>The command <command>nix-push</command> builds a set of store
paths (if necessary), and then packages and uploads all store paths in
the resulting closures to a server.  A network cache thus populated
can subsequently be used to speed up software deployment on other
machines using the <command>nix-pull</command> command.</para>

<para><command>nix-push</command> performs the following actions.
      
<orderedlist>

  <listitem><para>Each path in <replaceable>paths</replaceable> is
  realised (using <link
  linkend='rsec-nix-store-realise'><literal>nix-store
  --realise</literal></link>).</para></listitem>

  <listitem><para>All paths in the closure of the store expressions
  stored in <replaceable>paths</replaceable> are determined (using
  <literal>nix-store --query --requisites
  --include-outputs</literal>).  It should be noted that since the
  <option>--include-outputs</option> flag is used, you get a combined
  source/binary distribution.</para></listitem>

  <listitem><para>All store paths determined in the previous step are
  packaged and compressed into a <command>bzip</command>ped NAR
  archive (extension <filename>.nar.bz2</filename>).</para></listitem>

  <listitem><para>A <emphasis>manifest</emphasis> is created that
  contains information on the store paths, their eventual URLs in the
  cache, and cryptographic hashes of the contents of the NAR
  archives.</para></listitem>

  <listitem><para>Each store path is uploaded to the remote directory
  specified by <replaceable>archivesPutURL</replaceable>.  HTTP PUT
  requests are used to do this.  However, before a file
  <varname>x</varname> is uploaded to
  <literal><replaceable>archivesPutURL</replaceable>/</literal><varname>x</varname>,
  <command>nix-push</command> first determines whether this upload is
  unnecessary by issuing a HTTP HEAD request on
  <literal><replaceable>archivesGetURL</replaceable>/</literal><varname>x</varname>.
  This allows a cache to be shared between many partially overlapping
  <command>nix-push</command> invocations.  (We use two URLs because
  the upload URL typically refers to a CGI script, while the download
  URL just refers to a file system directory on the
  server.)</para></listitem>

  <listitem><para>The manifest is uploaded using an HTTP PUT request
  to <replaceable>manifestPutURL</replaceable>.  The corresponding
  URL to download the manifest can then be used by
  <command>nix-pull</command>.</para></listitem>
        
</orderedlist>

</para>

<!--
<para>TODO:  <option>- -copy</option></para>
-->
            
</refsection>


<refsection><title>Examples</title>

<para>To upload files there typically is some CGI script on the server
side.  This script should be be protected with a password.  The
following example uploads the store paths resulting from building the
Nix expressions in <filename>foo.nix</filename>, passing appropriate
authentication information:
    
<screen>
$ nix-push \
    http://foo@bar:server.domain/cgi-bin/upload.pl/cache \
    http://server.domain/cache \
    http://foo@bar:server.domain/cgi-bin/upload.pl/MANIFEST \
    $(nix-instantiate foo.nix)</screen>

This will push both sources and binaries (and any build-time
dependencies used in the build, such as compilers).</para>

<para>If we just want to push binaries, not sources and build-time
dependencies, we can do:
      
<screen>
$ nix-push <replaceable>urls</replaceable> $(nix-instantiate $(nix-store -r foo.nix))</screen>
    
</para>

</refsection>
    
</refentry>