Skip to content

Getting started

Snarf is currently best deployed as a NixOS module.

Setting up the server

Include Snarf's flake in your inputs and add it's module to your nixosSystem's modules:

inputs = {
  # ...
  snarf.url = "git+https://codeberg.org/pascalj/snarf";
};
outputs = {
  # ...
  snarf
}:
{
  #...
  nixosConfigurations.my-host = nixpkgs.lib.nixosSystem {
    modules = [
      ./configuration.nix
      snarf.nixosModules.default
    ];
  };
};

This makes the module available to your configuration. To get started, simply enable the server (snarfd) and configure its listening address:

{
  # ...
  services.snarf = {
    enable = true;
    # This will make your cache available publicly
    listenAddress = "0.0.0.0";
    openFirewall = true;
  };
}

Activate the configuration. You can navigate to your server on port 9000 to verify that the cache is up and running:

nix run nixpkgs#curl -- <your-server>:9000

This should output a response from the server.

Client

Use the client (snarf) to manage users, cache data and the configuration of the server. Initialize the server to get started with a fresh server.

export SNARF_SERVER_ADDRESS="<your-server>:9000"
snarf users init
# Or, if you don't have snarf installed:
# nix shell git+https://codeberg.org/jungblut/snarf -c snarf -- users init
This will return the admin token for your cache. Store it inside the SNARF_CLIENT_TOKEN environment variable to access the authenticated features of your cache server.

export SNARF_CLIENT_TOKEN="<client-token>"
snarf cache add /nix/store/...
# Or, if you don't have snarf installed:
# nix shell git+https://codeberg.org/jungblut/snarf -c snarf -- users init

This uploads the closure of the store path you provide to the store.