update-flake.sh 1012 B

1234567891011121314151617181920212223242526
  1. #!/bin/sh
  2. # Updates SRI hashes for flake.nix.
  3. set -eu
  4. OUT=$(mktemp -d -t nar-hash-XXXXXX)
  5. rm -rf "$OUT"
  6. ./tool/go mod vendor -o "$OUT"
  7. ./tool/go run tailscale.com/cmd/nardump --sri "$OUT" >go.mod.sri
  8. rm -rf "$OUT"
  9. GOOUT=$(mktemp -d -t gocross-XXXXXX)
  10. GOREV=$(xargs < ./go.toolchain.rev)
  11. TARBALL="$GOOUT/go-$GOREV.tar.gz"
  12. curl -Ls -o "$TARBALL" "https://github.com/tailscale/go/archive/$GOREV.tar.gz"
  13. tar -xzf "$TARBALL" -C "$GOOUT"
  14. ./tool/go run tailscale.com/cmd/nardump --sri "$GOOUT/go-$GOREV" > go.toolchain.rev.sri
  15. rm -rf "$GOOUT"
  16. # nix-direnv only watches the top-level nix file for changes. As a
  17. # result, when we change a referenced SRI file, we have to cause some
  18. # change to shell.nix and flake.nix as well, so that nix-direnv
  19. # notices and reevaluates everything. Sigh.
  20. perl -pi -e "s,# nix-direnv cache busting line:.*,# nix-direnv cache busting line: $(cat go.mod.sri)," shell.nix
  21. perl -pi -e "s,# nix-direnv cache busting line:.*,# nix-direnv cache busting line: $(cat go.mod.sri)," flake.nix