Home Explore Blog CI



nix

1st chunk of `src/nix/flake-archive.md`
bca9b4d4e1485288da295861eb729943b0729608fc5847c10000000100000354
R""(

# Examples

* Copy the `dwarffs` flake and its dependencies to a binary cache:

  ```console
  # nix flake archive --to file:///tmp/my-cache dwarffs
  ```

* Fetch the `dwarffs` flake and its dependencies to the local Nix
  store:

  ```console
  # nix flake archive dwarffs
  ```

* Print the store paths of the flake sources of NixOps without
  fetching them:

  ```console
  # nix flake archive --json --dry-run nixops
  ```

* Upload all flake inputs to a different machine for remote evaluation

  ```
  # nix flake archive --to ssh://some-machine
  ```

  On the remote machine the flake can then be accessed via its store path. That's computed like this:

  ```
  # nix flake metadata --json | jq -r '.path'
  ```

# Description

Copy a flake and all its inputs to a store. This is useful i.e. to evaluate flakes on a different host.

)""

Title: Nix Flake Archive Examples and Description
Summary
This section provides examples and a description of the `nix flake archive` command. This command copies a flake and all its inputs to a store, which is useful for evaluating flakes on a different host. Examples demonstrate copying to a binary cache, fetching to the local store, printing store paths without fetching, and uploading flake inputs to a remote machine. It also explains how to access the flake via its store path on the remote machine.