nix-config/.envrc
2024-07-28 21:52:06 -04:00

23 lines
531 B
Plaintext

watch_file flake.in.nix
# Calculate the hash of flake.in.nix
current_hash=$(md5sum flake.in.nix | cut -d ' ' -f 1)
stored_hash_file=".flake_in_nix_hash"
# Read the stored hash if it exists
if [ -f "$stored_hash_file" ]; then
stored_hash=$(cat "$stored_hash_file")
else
stored_hash=""
fi
# Compare the hashes and copy if they are different
if [ "$current_hash" != "$stored_hash" ]; then
cp $(nix eval --raw .#nextFlake) flake.nix
# Store the new hash
echo "$current_hash" > "$stored_hash_file"
fi
use_flake