From 6fd12d439041d62ba96a3c71f066185be363899d Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Thu, 12 Feb 2026 16:54:05 -0600 Subject: [PATCH] build: add build-deps make target for nix bootstrap --- CONTRIBUTING.md | 18 ++++++++++++++++++ Makefile | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4c3ca130..f0a5f3ff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,3 +32,21 @@ Headscale is open to code contributions for bug fixes without discussion. ## Documentation If you find mistakes in the documentation, please submit a fix to the documentation. + +## Building with Visual Studio Code + +If you prefer using VS Code for day-to-day development, use the integrated terminal from the repository root and: + +1. Start the Nix development environment first (choose one): + + - Direct command: `nix develop --extra-experimental-features nix-command --extra-experimental-features flakes` + - Make target: `make build-deps` + +2. Run the standard Make targets: + + - `make build` to compile the headscale binary + - `make test` to run the test suite + - `make fmt` to format code and docs + - `make lint` to run lint checks + +Recommended VS Code extensions: Go (`golang.go`), Nix IDE (`jnoortheen.nix-ide`), Prettier (`esbenp.prettier-vscode`), and YAML (`redhat.vscode-yaml`). diff --git a/Makefile b/Makefile index 1e08cda9..f4f19d79 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,17 @@ check-deps: $(call check_tool,clang-format) $(call check_tool,buf) + +# Development environment bootstrap +.PHONY: build-deps +build-deps: + @command -v nix >/dev/null 2>&1 || { \ + echo "Error: nix not found. Install Nix to use build-deps."; \ + exit 1; \ + } + @echo "Bootstrapping development dependencies via Nix..." + nix develop --extra-experimental-features nix-command --extra-experimental-features flakes --command true + # Build targets .PHONY: build build: check-deps $(GO_SOURCES) go.mod go.sum @@ -107,6 +118,7 @@ help: @echo "Main targets:" @echo " all - Run lint, test, and build (default)" @echo " build - Build headscale binary" + @echo " build-deps - Bootstrap development dependencies via Nix" @echo " test - Run Go tests" @echo " fmt - Format all code (Go, docs, proto)" @echo " lint - Lint all code (Go, proto)" @@ -123,6 +135,7 @@ help: @echo "" @echo "Dependencies:" @echo " check-deps - Verify required tools are available" + @echo " build-deps - Prepare development dependencies (Nix)" @echo "" @echo "Note: If not running in a nix shell, ensure dependencies are available:" @echo " nix develop"