WIP! A BB-style forum, on the ATmosphere! We're still working... we'll be back soon when we have something to show off!
node typescript hono htmx atproto
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

at fix/backfill-theme-collections 88 lines 3.3 kB view raw
1#!/usr/bin/env bash 2set -eo pipefail 3 4SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 5PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" 6PACKAGE_NIX="$PROJECT_ROOT/nix/package.nix" 7 8# lib.fakeHash — a structurally valid but incorrect sha256 that forces Nix 9# to report the actual hash of whatever it fetches. 10FAKE_HASH="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" 11 12# --------------------------------------------------------------------------- 13# Platform check 14# --------------------------------------------------------------------------- 15# The Nix flake only targets x86_64-linux / aarch64-linux. pnpm fetchDeps 16# downloads platform-specific optional packages (e.g. @esbuild/darwin-arm64 17# vs @esbuild/linux-arm64), so a macOS pnpm fetch produces a different hash 18# than a Linux one. This script must run on Linux or use a remote Linux 19# Nix builder to produce the correct hash. 20# --------------------------------------------------------------------------- 21if [[ "$(uname)" == "Darwin" ]]; then 22 echo "WARNING: This script should run on Linux (or via a Linux Nix remote builder)." 23 echo "" 24 echo "The Nix flake targets x86_64-linux/aarch64-linux only. When pnpm fetches" 25 echo "on macOS it downloads darwin-specific optional packages (@esbuild/darwin-arm64," 26 echo "etc.), producing a different hash than the Linux build expects." 27 echo "" 28 echo "Options:" 29 echo " 1. SSH into a Linux machine and run this script there" 30 echo " 2. Configure a Linux Nix remote builder in ~/.config/nix/nix.conf" 31 echo " 3. Push to CI, copy the correct hash from the build error output," 32 echo " then update nix/package.nix manually" 33 echo "" 34 read -p "Continue anyway (e.g. you have a remote builder configured)? [y/N] " -n 1 -r 35 echo 36 if [[ ! $REPLY =~ ^[Yy]$ ]]; then 37 exit 0 38 fi 39fi 40 41echo "Updating pnpmDeps hash in nix/package.nix..." 42 43# Extract current hash 44CURRENT_HASH=$(grep -oP '(?<=hash = ")[^"]+' "$PACKAGE_NIX") 45echo " Current: $CURRENT_HASH" 46 47# Swap in the fake hash so Nix is forced to compute and report the real one 48if [[ "$(uname)" == "Darwin" ]]; then 49 sed -i '' "s|$CURRENT_HASH|$FAKE_HASH|" "$PACKAGE_NIX" 50else 51 sed -i "s|$CURRENT_HASH|$FAKE_HASH|" "$PACKAGE_NIX" 52fi 53 54echo " Running: nix build .#packages.x86_64-linux.default" 55echo " (Nix will fail with a hash mismatch — that is expected)" 56 57BUILD_OUTPUT=$(nix build .#packages.x86_64-linux.default 2>&1 || true) 58 59# Nix prints: " got: sha256-<actual hash>" 60NEW_HASH=$(echo "$BUILD_OUTPUT" | grep "got:" | awk '{print $NF}' | head -1) 61 62if [ -z "$NEW_HASH" ]; then 63 echo "" 64 echo "ERROR: Could not parse the correct hash from nix output." 65 echo "" 66 echo "Full build output:" 67 echo "$BUILD_OUTPUT" 68 echo "" 69 echo "Restoring original hash..." 70 if [[ "$(uname)" == "Darwin" ]]; then 71 sed -i '' "s|$FAKE_HASH|$CURRENT_HASH|" "$PACKAGE_NIX" 72 else 73 sed -i "s|$FAKE_HASH|$CURRENT_HASH|" "$PACKAGE_NIX" 74 fi 75 exit 1 76fi 77 78# Write the real hash back 79if [[ "$(uname)" == "Darwin" ]]; then 80 sed -i '' "s|$FAKE_HASH|$NEW_HASH|" "$PACKAGE_NIX" 81else 82 sed -i "s|$FAKE_HASH|$NEW_HASH|" "$PACKAGE_NIX" 83fi 84 85echo " Updated: $NEW_HASH" 86echo "" 87echo "Commit the change:" 88echo " git add nix/package.nix && git commit -m 'chore: adjust pnpmdeps hash'"