Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 36 additions & 41 deletions doc/manual/src/command-ref/nix-copy-closure.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Name

`nix-copy-closure` - copy a closure to or from a remote machine via SSH
`nix-copy-closure` - copy store objects to or from a remote machine via SSH
Comment thread
fricklerhandwerk marked this conversation as resolved.

# Synopsis

`nix-copy-closure`
[`--to` | `--from`]
[`--to` _machine_ | `--from` _machine_]
[`--gzip`]
[`--include-outputs`]
[`--use-substitutes` | `-s`]
Expand All @@ -14,62 +14,57 @@

# Description

`nix-copy-closure` gives you an easy and efficient way to exchange
software between machines. Given one or more Nix store _paths_ on the
local machine, `nix-copy-closure` computes the closure of those paths
(i.e. all their dependencies in the Nix store), and copies all paths
in the closure to the remote machine via the `ssh` (Secure Shell)
command. With the `--from` option, the direction is reversed: the
closure of _paths_ on a remote machine is copied to the Nix store on
the local machine.

This command is efficient because it only sends the store paths
that are missing on the target machine.

Since `nix-copy-closure` calls `ssh`, you may be asked to type in the
appropriate password or passphrase. In fact, you may be asked _twice_
because `nix-copy-closure` currently connects twice to the remote
machine, first to get the set of paths missing on the target machine,
and second to send the dump of those paths. When using public key
authentication, you can avoid typing the passphrase with `ssh-agent`.
`nix-copy-closure` copies [store objects](@docroot@/glossary.md#gloss-store-object) along with all their dependencies to or from another machine via the SSH protocol.
It doesn’t copy store objects that are already present on the target machine.

Given one or more _paths_ accesible from the client, `nix-copy-closure` computes the [closure](@docroot@/glossary.md#gloss-closure) of those paths (i.e. all their dependencies in the Nix store), and copies all store objects in the closure to the remote machine via SSH.
Comment thread
fricklerhandwerk marked this conversation as resolved.
Outdated
With the `--from` option, the direction is reversed:
Comment thread
fricklerhandwerk marked this conversation as resolved.
Outdated
The closure of _paths_ on a remote machine is copied to the specified Nix store accessible from the client.

This command is efficient because it only sends the store paths that are missing on the target machine.
Comment thread
fricklerhandwerk marked this conversation as resolved.
Outdated

> **Note**
>
> While the Nix store to use on the client can be specified on the command line with the [`--store`](@docroot@/command-ref/conf-file.md#conf-store) option, the Nix store to be accessed on the remote machine can only be [configured statically](@docroot@/command-ref/conf-file.md#configuration-file) on that remote machine.
Comment thread
fricklerhandwerk marked this conversation as resolved.
Outdated

Since `nix-copy-closure` calls `ssh`, you may need to authenticate with the remote machine.
In fact, you may be asked for authentication _twice_ because `nix-copy-closure` currently connects twice to the remote machine: first to get the set of paths missing on the target machine, and second to send the dump of those paths.
When using public key authentication, you can avoid typing the passphrase with `ssh-agent`.

# Options

- `--to`\
Copy the closure of _paths_ from the local Nix store to the Nix
store on _machine_. This is the default.
- `--to` _machine_

Copy the closure of _paths_ from the local Nix store to the Nix store on _machine_.
This is the default.
Comment thread
fricklerhandwerk marked this conversation as resolved.
Outdated

- `--from`\
Copy the closure of _paths_ from the Nix store on _machine_ to the
local Nix store.
- `--from` _machine_

Copy the closure of _paths_ from the Nix store on _machine_ to the local Nix store.

- `--gzip`

- `--gzip`\
Enable compression of the SSH connection.

- `--include-outputs`\
- `--include-outputs`

Also copy the outputs of [store derivation]s included in the closure.

[store derivation]: @docroot@/glossary.md#gloss-store-derivation

- `--use-substitutes` / `-s`\
Attempt to download missing paths on the target machine using Nix’s
substitute mechanism. Any paths that cannot be substituted on the
target are still copied normally from the source. This is useful,
for instance, if the connection between the source and target
machine is slow, but the connection between the target machine and
`nixos.org` (the default binary cache server) is
fast.
- `--use-substitutes` / `-s`

- `-v`\
Show verbose output.
Attempt to download missing store objects on the target from [substituters](@docroot@/command-ref/conf-file.md#conf-substituters).
Any store objects that cannot be substituted on the target are still copied normally from the source.
This is useful, for instance, if the connection between the source and target machine is slow, but the connection between the target machine and `nixos.org` (the default binary cache server) is fast.
Comment thread
fricklerhandwerk marked this conversation as resolved.
Outdated

{{#include ./opt-common.md}}

# Environment variables

- `NIX_SSHOPTS`\
Additional options to be passed to `ssh` on the command
line.
- `NIX_SSHOPTS`

Additional options to be passed to `ssh` on the command line.
Comment thread
fricklerhandwerk marked this conversation as resolved.

{{#include ./env-common.md}}

Expand Down