# Build exactly what devenv installs; ./result links to the store path. # Files must be tracked by git to be seen (jj tracks new files for you). build: clean @echo "Building with nix..." @nix build . @./result/bin/bug version .PHONY: build clean: @# Remove result directory/symlink @rm -rf result @rm -rf bin/ .PHONY: clean fmt: go fmt ./... .PHONY: fmt lint: golangci-lint run .PHONY: lint test: go test -tags integration -timeout 5m ./... .PHONY: test # Update flake.nix vendorHash when go.mod/go.sum changes # This target depends on go.mod and go.sum, so it will only run when they change update-vendor-hash: flake.nix go.mod go.sum @echo "Checking if vendorHash needs update..." @nix build 2>&1 | tee /tmp/nix-build.log; \ if grep -q "hash mismatch" /tmp/nix-build.log; then \ NEW_HASH=$$(grep "got:" /tmp/nix-build.log | sed 's/.*got: *//' | tail -1); \ echo "Updating vendorHash to $$NEW_HASH"; \ sed -i "s|vendorHash = \"sha256-[^\"]*\";|vendorHash = \"$$NEW_HASH\";|" flake.nix; \ sed -i "s|vendorHash = pkgs.lib.fakeHash;|vendorHash = \"$$NEW_HASH\";|" flake.nix; \ elif grep -q "error:.*fakeHash" /tmp/nix-build.log; then \ NEW_HASH=$$(grep "got:" /tmp/nix-build.log | sed 's/.*got: *//' | tail -1); \ echo "Updating vendorHash to $$NEW_HASH"; \ sed -i "s|vendorHash = pkgs.lib.fakeHash;|vendorHash = \"$$NEW_HASH\";|" flake.nix; \ else \ echo "vendorHash is up to date"; \ fi @rm -f /tmp/nix-build.log @touch update-vendor-hash .PHONY: update-vendor-hash # Update flake.lock when flake.nix inputs change update-flake-lock: flake.nix nix flake lock touch update-flake-lock .PHONY: update-flake-lock # Update both vendor hash and flake lock update-flake: update-vendor-hash update-flake-lock @echo "Flake updated successfully" .PHONY: update-flake