|
| 1 | +{ pkgs, lib, config, ... }: |
| 2 | + |
| 3 | +{ |
| 4 | + # https://devenv.sh/basics/ |
| 5 | + # A reproducible Go development environment for moq-go. |
| 6 | + |
| 7 | + # https://devenv.sh/languages/ |
| 8 | + # Provides the Go toolchain (matching go.mod's `go 1.26`) plus go env wiring. |
| 9 | + languages.go.enable = true; |
| 10 | + |
| 11 | + # https://devenv.sh/packages/ |
| 12 | + # Tooling the repo expects on PATH. The lint config (.golangci.yml) enables the |
| 13 | + # `goimports` and `golines` formatters, so both must be available. |
| 14 | + packages = with pkgs; [ |
| 15 | + golangci-lint # `golangci-lint run` — see .golangci.yml |
| 16 | + golines # long-line formatter enabled in .golangci.yml |
| 17 | + gotools # provides goimports |
| 18 | + gopls # language server |
| 19 | + delve # `dlv` debugger |
| 20 | + gnumake # the Makefile drives build/test/interop targets |
| 21 | + ]; |
| 22 | + |
| 23 | + # https://devenv.sh/scripts/ |
| 24 | + # Thin wrappers around the canonical commands from CLAUDE.md / the Makefile. |
| 25 | + scripts.build.exec = "go build ./..."; |
| 26 | + scripts.test.exec = "go test ./..."; |
| 27 | + scripts.test-race.exec = "go test -race ./..."; |
| 28 | + scripts.lint.exec = "golangci-lint run"; |
| 29 | + scripts.bench.exec = "go test -run='^$' -bench=. -benchmem ./..."; |
| 30 | + # modernize check (errorsastype) — see CLAUDE.md; run standalone until |
| 31 | + # golangci-lint bundles the analyzer. Pass -fix to apply. |
| 32 | + scripts.modernize.exec = '' |
| 33 | + go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest \ |
| 34 | + -errorsastype "$@" ./... |
| 35 | + ''; |
| 36 | + |
| 37 | + enterShell = '' |
| 38 | + echo "moq-go devenv — go $(go version | cut -d' ' -f3 | sed 's/go//')" |
| 39 | + echo " scripts: build | test | test-race | lint | bench | modernize" |
| 40 | + ''; |
| 41 | + |
| 42 | + # https://devenv.sh/tests/ |
| 43 | + # `devenv test` sanity-checks the toolchain wiring. |
| 44 | + enterTest = '' |
| 45 | + go version |
| 46 | + golangci-lint version |
| 47 | + ''; |
| 48 | +} |
0 commit comments