nix-pushpush store paths onto a network cachenix-pusharchivesPutURLarchivesGetURLmanifestPutURLarchivesDirmanifestFilepathsDescriptionThe command nix-push 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 nix-pull command.nix-push performs the following actions.
Each path in paths is
realised (using nix-store
--realise).All paths in the closure of the store expressions
stored in paths are determined (using
nix-store --query --requisites
--include-outputs). It should be noted that since the
flag is used, you get a combined
source/binary distribution.All store paths determined in the previous step are
packaged and compressed into a bzipped NAR
archive (extension .nar.bz2).A manifest 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.Each store path is uploaded to the remote directory
specified by archivesPutURL. HTTP PUT
requests are used to do this. However, before a file
x is uploaded to
archivesPutURL/x,
nix-push first determines whether this upload is
unnecessary by issuing a HTTP HEAD request on
archivesGetURL/x.
This allows a cache to be shared between many partially overlapping
nix-push 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.)The manifest is uploaded using an HTTP PUT request
to manifestPutURL. The corresponding
URL to download the manifest can then be used by
nix-pull.ExamplesTo 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 foo.nix, passing appropriate
authentication information:
$ 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)
This will push both sources and binaries (and any build-time
dependencies used in the build, such as compilers).If we just want to push binaries, not sources and build-time
dependencies, we can do:
$ nix-push urls $(nix-instantiate $(nix-store -r foo.nix))