diff --git a/bin/nix-build-and-cache b/bin/nix-build-and-cache index 3810cd19..c0969a24 100755 --- a/bin/nix-build-and-cache +++ b/bin/nix-build-and-cache @@ -10,14 +10,6 @@ just() { nix build "$@" fi - if [ -z ${ATTIC_TOKEN+x} ]; then - echo "\$ATTIC_TOKEN is unset, skipping uploading to the binary cache" - return - fi - - nix run --inputs-from . attic#default -- \ - login "$ATTIC_SERVER" "$ATTIC_ENDPOINT" "$ATTIC_TOKEN" - # Find all output paths of the installables and their build dependencies readarray -t derivations < <(nix path-info --derivation "$@") readarray -t cache < <( @@ -26,6 +18,14 @@ just() { <<< "${derivations[*]}" ) + if [ -z ${ATTIC_TOKEN+x} ]; then + echo "\$ATTIC_TOKEN is unset, skipping uploading to the binary cache" + return + fi + + nix run --inputs-from . attic#default -- \ + login "$ATTIC_SERVER" "$ATTIC_ENDPOINT" "$ATTIC_TOKEN" + # Upload them to Attic. It seems to insist on newlines to separate the # paths. (