From 85b9080c77848839d25fba72ac4f4adb3ccb4fd9 Mon Sep 17 00:00:00 2001 From: Charles Hall Date: Wed, 30 Jul 2025 10:00:48 -0700 Subject: [PATCH] change working directory Did you know installables are parsed with regex? This mitigates how horrifying that is. --- bin/nix-build-and-cache | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/nix-build-and-cache b/bin/nix-build-and-cache index 54e45aee..fe1ed381 100755 --- a/bin/nix-build-and-cache +++ b/bin/nix-build-and-cache @@ -2,8 +2,6 @@ set -euo pipefail -toplevel="$(git rev-parse --show-toplevel)" - # Build and cache the specified arguments just() { if command -v nom &> /dev/null; then @@ -17,7 +15,7 @@ just() { return fi - nix run --inputs-from "$toplevel" attic -- \ + nix run --inputs-from . attic -- \ login \ "$ATTIC_SERVER" \ "$ATTIC_ENDPOINT" \ @@ -38,7 +36,7 @@ just() { # store paths include a newline in them. ( IFS=$'\n' - nix shell --inputs-from "$toplevel" attic -c xargs \ + nix shell --inputs-from . attic -c xargs \ attic push "$ATTIC_SERVER:$ATTIC_CACHE" <<< "${cache[*]}" ) } @@ -46,10 +44,10 @@ just() { # Build and cache things needed for CI ci() { cache=( - --inputs-from "$toplevel" + --inputs-from . # Keep sorted - "$toplevel#devShells.x86_64-linux.default" + ".#devShells.x86_64-linux.default" attic#default nixpkgs#direnv nixpkgs#jq @@ -63,12 +61,14 @@ ci() { packages() { readarray -t cache < <( nix flake show --json 2> /dev/null | - nix run --inputs-from "$toplevel" nixpkgs#jq -- \ + nix run --inputs-from . nixpkgs#jq -- \ -r \ - '.packages."x86_64-linux" | keys | map("'"$toplevel"'#" + .) | .[]' + '.packages."x86_64-linux" | keys | map(".#" + .) | .[]' ) just "${cache[@]}" } +pushd "$(git rev-parse --show-toplevel)" > /dev/null "$@" +popd > /dev/null