Skip to content

Commit 9fec796

Browse files
committed
Fix ghcr-upload.sh: null byte crash from binary NAR in store-paths.txt
The old code piped `nix-store --export` (binary NAR output containing null bytes) through `tee store-paths.txt`, then used `tail -n 1` on that binary file inside $() — bash on Ubuntu 24.04 errors out with "command substitution: ignored null byte in input". Fix: capture the text path list from `nix-store -qR` in a variable first, then use grep to verify the -env.sh script is in the closure.
1 parent a09f39d commit 9fec796

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

extra/ghcr-upload.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ set -euox pipefail
77

88
# retry three times in case of intermittent network errors.
99
nix-store -r "$SHELL_NIX_PATH" || nix-store -r "$SHELL_NIX_PATH" || nix-store -r "$SHELL_NIX_PATH"
10-
#nix build ".#hydraJobs.${DEV_SHELL}" --show-trace --accept-flake-config
11-
nix-store --export $(nix-store -qR "$SHELL_NIX_PATH") | tee store-paths.txt | zstd -z8T8 >${DEV_SHELL}
12-
# Verify the environment script is included in the closure
13-
# The script filename ends with -env.sh (e.g., ghc96-env.sh, ghc98-static-iog-env.sh)
14-
if [[ ! $(tail -n 1 store-paths.txt) =~ "-env.sh" ]]; then exit 1; fi
10+
# Collect closure paths and export them as a zstd-compressed NAR archive.
11+
# Save the path list separately for verification — nix-store --export
12+
# produces binary output (contains null bytes) which can't be inspected
13+
# with text tools like tail/grep.
14+
CLOSURE_PATHS=$(nix-store -qR "$SHELL_NIX_PATH")
15+
nix-store --export $CLOSURE_PATHS | zstd -z8T8 >${DEV_SHELL}
16+
# Verify the environment script is included in the closure.
17+
# The script filename ends with -env.sh (e.g., ghc96-env.sh, ghc98-static-iog-env.sh).
18+
if ! echo "$CLOSURE_PATHS" | grep -q -- "-env\.sh$"; then exit 1; fi
1519
oras push ghcr.io/input-output-hk/devx:${DEV_SHELL} ${DEV_SHELL}

0 commit comments

Comments
 (0)