# nix-cache-watcher
## Table of Contents
- [About](#about)
- [Getting Started](#getting_started)
- [Usage](#usage)
- [Contributing](doc/contributing.md)
- [CHANGELOG.md](CHANGELOG.md)
## About <a name = "about"></a>
A very WIP tool for uploading Nix build artifacts to an s3 compatible binary cache. This will
eventually support direct upload to s3/b2, and possibly direct singing, but at the moment it shells
out to the nix to perform those operations.
Takes a snapshot of your nix store state before your build, and then signs and uploads new
installable afterwards.
## Getting Started <a name = "getting_started"></a>
### Prerequisites
This program is only intended to run on systems with `nix` installed, and has the following
dependencies:
- `xz`
- `curl`
### Installing
Install though cargo:
```sh
cargo install nix-cache-watcher
```
or through [Nix](https://nixos.org/learn.html):
```sh
nix registry add nix-cache-watcher 'git+https://git.sr.ht/~thatonelutenist/nix-cache-watcher?ref=trunk'
nix build nix-cache-watcher# --profile /home/build/.nix-profile
```
## Usage
See `nix-cache-watcher --help` for full syntax and options.
Before starting your build, you must take a snapshot of the current nix store state:
```sh
nix-cache-watcher save-store
```
Then, run your build. After your build completes, first sign the new store paths, and then send them
off for upload:
```sh
nix-cache-watcher sign-store -k $PATH_TO_KEY
nix-cache-watcher upload-diff -r "$CACHE_URI" -v
```
Note: you must already have your AWS SDK credentials configured for this to work.