#!/bin/sh echo "nix-cache: Storing new store items" NEW_NIX_STORE_CONTENTS_FILE=$(mktemp) find /nix/store/ -maxdepth 1 > $NEW_NIX_STORE_CONTENTS_FILE sort $OLD_NIX_STORE_CONTENTS_FILE -o $OLD_NIX_STORE_CONTENTS_FILE sort $NEW_NIX_STORE_CONTENTS_FILE -o $NEW_NIX_STORE_CONTENTS_FILE echo "nix-cache: Comparing store paths" FILTERED_NIX_STORE_CONTENTS_FILE=$(mktemp) comm -13 $OLD_NIX_STORE_CONTENTS_FILE $NEW_NIX_STORE_CONTENTS_FILE > $FILTERED_NIX_STORE_CONTENTS_FILE echo "nix-cache: New store paths:" cat $FILTERED_NIX_STORE_CONTENTS_FILE | sed 's/^/ /g' if test -n "$(head -n1 $FILTERED_NIX_STORE_CONTENTS_FILE)"; then echo "nix-cache: Sending new paths to cache" nix copy --to "$STORE_URL" $(cat $FILTERED_NIX_STORE_CONTENTS_FILE) || true else echo "nix-cache: Nothing to send" fi