Skip to content

Client

Use the snarf client to manage data and users on the server.

It supports three commands:

  • users: Manage users and permissions.
  • cache: Manage the data in the cache.
  • upstream-caches: Configure upstream caches.

users: Manage Users

init: Initialize a Server

When the server is first starting up, it is in an uninitialized state. To initialize it and to create the admin client token, use the snarf user init command. It queries the (uninitialized) server and prints out a client token.

Save that client token, since you can generate it only once. All other commands require the client token to work.

add: Create a Token

Once the server is initialized, use users add to create additional tokens with specific permissions. Pass one or more permission names as arguments:

  • Admin — can manage users, tokens, and upstream caches
  • Upload — can upload store paths to the cache

Example (create an upload-only token):

snarf --token $SNARF_CLIENT_TOKEN users add Upload

Example (create a token with both permissions):

snarf --token $SNARF_CLIENT_TOKEN users add Admin Upload

The new token is printed to stdout. You need an Admin token to create new tokens.

cache: Manage Data in the Cache

add: Upload a Closure to the Cache

When you want to add a closure, that is a store path and all its references and their references, to the cache, use the add command.

Snarf will first check whether any data is available in the configured upstream caches and skip them.

Example:

snarf cache add /nix/store/hhg83gh653wjw4ny49xn92f13v2j1za4-hello-2.12.2/bin/hello

upstream-caches: Manage Upstream Caches

Snarf will skip all NAR archives that are already available in upstream caches.

add: Add an Upstream Cache

Add an upstream cache by adding its URL:

Example:

snarf upstream-caches add https://cache.nixos.org

list: List Upstream Caches

Get a list of all configured upstream caches. This list is saved on the server and is used for all clients interacting with the server.

Example:

snarf upstream-caches list

remove: Remove an Upstream Cache

Remove an upstream cache by its URL:

Example:

snarf upstream-caches remove https://cache.nixos.org