server/scripts/update-nix.sh

24 lines
714 B
Bash
Raw Permalink Normal View History

2025-06-15 22:26:43 +02:00
#!/usr/bin/env bash
set -euo pipefail
# Step 2: Blank the hash in package.nix
sed -i 's/outputHash = ".*";/outputHash = lib.fakeHash;/g' nix/package.nix
2025-06-15 22:26:43 +02:00
echo "Running nix build to get the correct hash..."
# Step 3: Run nix build and capture stderr
build_output=$(nix build .#versia-server 2>&1 || true)
# Step 4: Extract the corrected hash from the output
corrected_hash=$(echo "$build_output" | grep 'got:' | awk '{print $2}')
echo "Corrected hash: $corrected_hash"
# Step 5: Replace the blank hash with the corrected one
sed -i "s/outputHash = lib.fakeHash;/outputHash = \"$corrected_hash\";/g" nix/package.nix
2025-06-15 22:26:43 +02:00
echo "Rebuilding with the corrected hash..."
# Step 6: Build again
nix build .#versia-server