#!/usr/bin/env bash set -euo pipefail # The first argument must be the desired installable INSTALLABLE="$1" # Build the installable and forward any other arguments too. Also, use # nix-output-monitor instead if it's available. if command -v nom &> /dev/null; then nom build "$@" else nix build "$@" fi if [ ! -z ${ATTIC_TOKEN+x} ]; then nix run --inputs-from . attic -- \ login \ "$ATTIC_SERVER" \ "$ATTIC_ENDPOINT" \ "$ATTIC_TOKEN" # Push the target installable and its build dependencies nix run --inputs-from . attic -- \ push \ "$ATTIC_SERVER:$ATTIC_CACHE" \ "$(nix path-info "$INSTALLABLE" --derivation)" \ "$(nix path-info "$INSTALLABLE")" else echo "\$ATTIC_TOKEN is unset, skipping uploading to the binary cache" fi