From fd8e6bb515974402bf9a46dfa997fe18c78a58b7 Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 9 Mar 2026 08:45:06 -0700 Subject: [PATCH 01/10] simplify docs target --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index c387c8c9..c7ecb7ab 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,6 @@ GO_DEPS := $(GO_SOURCES) go.mod go.sum MIGRATE_DIR := sql/migrations DB_URL := sqlite3://dev.db -DOCS_DEPS := $(wildcard internal/api/handlers/*.go) -DOCS_TARGET := internal/api/docs/docs.go SQLC_DEPS := $(wildcard sql/migrations/*.sql) $(wildcard sql/queries/*.sql) SQLC_TARGET := internal/api/dbmodels/models.go @@ -25,7 +23,7 @@ build: api cli ## Build the api and cli binaries api: $(BIN_DIR)/$(API_NAME) ## Build the api binary -$(BIN_DIR)/$(API_NAME): $(GO_DEPS) $(SQLC_TARGET) +$(BIN_DIR)/$(API_NAME): $(GO_DEPS) sqlc @mkdir -p $(BIN_DIR) go build -ldflags "-X main.Version=$(VERSION)" -o $(BIN_DIR)/$(API_NAME) ./cmd/$(API_NAME) @@ -35,11 +33,13 @@ $(BIN_DIR)/$(CLI_NAME): $(GO_DEPS) @mkdir -p $(BIN_DIR) go build -ldflags "-X cli.Version=$(VERSION)" -o $(BIN_DIR)/$(CLI_NAME) ./cmd/$(CLI_NAME) -generate: $(DOCS_TARGET) $(SQLC_TARGET) ## Generate all necessary files with +generate: swag sqlc ## Generate all necessary files -$(DOCS_TARGET): $(DOCS_DEPS) +swag: ## Generate OpenAPI docs swag init -d cmd/acmcsuf-api,internal/api/handlers,internal/api/dbmodels -o internal/api/docs --parseDependency +sqlc: $(SQLC_TARGET) ## Generate dbmodels package with sqlc + $(SQLC_TARGET): $(SQLC_DEPS) sqlc generate @@ -47,7 +47,7 @@ fmt: ## Format all go files @go fmt ./... check: ## Run static analysis on all go files - staticcheck -f stylish ./... + staticcheck -f stylish ./... test: check ## Run all tests go test ./... From 10806cae4c4a05a6068a3837a82deb703bea3ca2 Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 9 Mar 2026 08:56:04 -0700 Subject: [PATCH 02/10] add generate check to ci --- .github/workflows/ci.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4cab4303..7df5b883 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,6 +23,7 @@ jobs: - "**/*.sql" - "go.mod" - "go.sum" + - "Makefile" - name: Install Nix if: steps.filter.outputs.source_code == 'true' @@ -44,6 +45,10 @@ jobs: if: steps.filter.outputs.source_code == 'true' run: nix develop -c make build + - name: Generated Files check + if: steps.filter.outputs.source_code == 'true' + run: nix develop -c bash -c "make generate && git diff --exit-code" + - name: Test if: steps.filter.outputs.source_code == 'true' run: nix develop -c make test From fe31f8c80e6a80f13a4976078d059b2d6344feb2 Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 9 Mar 2026 09:05:28 -0700 Subject: [PATCH 03/10] remove goroot getting set in shellhook --- nix/shell.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/nix/shell.nix b/nix/shell.nix index 4b38b357..f9339643 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -49,6 +49,5 @@ mkShell { cp .env.example .env fi echo -e "\e[32mLoaded nix dev shell\e[0m" - export GOROOT="${go}/share/go" ''; } From e6862a8d27ca55c35b46a699b7273d46aa853dad Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 9 Mar 2026 09:20:54 -0700 Subject: [PATCH 04/10] make sqlite-web an optional dependency in dev shell --- flake.nix | 5 +++- nix/shell.nix | 70 +++++++++++++++++++++++++-------------------------- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/flake.nix b/flake.nix index f46d6981..de4db3f5 100644 --- a/flake.nix +++ b/flake.nix @@ -30,7 +30,10 @@ }; in { packages.default = package; - devShells.default = pkgs.callPackage ./nix/shell.nix {}; + devShells = { + default = pkgs.callPackage ./nix/shell.nix {}; + full = pkgs.callPackage ./nix/shell.nix {full = true;}; + }; apps = { default = acmcsuf-api; diff --git a/nix/shell.nix b/nix/shell.nix index f9339643..c0747a2b 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -1,5 +1,6 @@ { mkShell, + lib, go, gopls, delve, @@ -7,47 +8,46 @@ air, sqlfluff, gnumake, - curl, xh, - jq, go-swag, cobra-cli, go-tools, go-migrate, sqlite, sqlite-web, -}: - -let - go-migrate-sqlite = go-migrate.overrideAttrs (oldAttrs: { - tags = [ "sqlite3" ]; - }); + full ? false, +}: let + go-migrate-sqlite = go-migrate.overrideAttrs (oldAttrs: { + tags = ["sqlite3"]; + }); in -mkShell { - packages = [ - go - gopls # Go language server - go-tools - delve # Go debugger - sqlc # compiles SQL queries to Go code - air # run dev server with hot reload - sqlfluff # SQL linter - gnumake - curl - xh - jq - go-swag - cobra-cli - go-migrate-sqlite - sqlite - sqlite-web - ]; + mkShell { + packages = + [ + go + gopls # Go language server + go-tools + delve # Go debugger + sqlc # compiles SQL queries to Go code + air # run dev server with hot reload + sqlfluff # SQL linter + gnumake + xh + go-swag + cobra-cli + go-migrate-sqlite + sqlite + ] + ++ lib.optionals full [ + # Heavyweight/optional dependencies + sqlite-web + ]; - shellHook = '' - if [ ! -f .env ]; then - echo ".env file not found! Creating one from .env.example for you..." - cp .env.example .env - fi - echo -e "\e[32mLoaded nix dev shell\e[0m" - ''; -} + shellHook = '' + if [ ! -f .env ]; then + echo ".env file not found! Creating one from .env.example for you..." + cp .env.example .env + fi + echo -e "\e[32mLoaded nix dev shell\e[0m" + ''; + } From 39c9870cfaa9dddfebb7f984a176d4bdf9c51a83 Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 9 Mar 2026 09:23:44 -0700 Subject: [PATCH 05/10] organize flake --- flake.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index de4db3f5..b94ee02c 100644 --- a/flake.nix +++ b/flake.nix @@ -23,25 +23,25 @@ package = pkgs.callPackage ./nix/package.nix { version = version; }; - acmcsuf-api = { type = "app"; program = "${package}/bin/acmcsuf-api"; }; + acmcsuf-cli = { + type = "app"; + program = "${package}/bin/acmcsuf-cli"; + }; in { - packages.default = package; devShells = { default = pkgs.callPackage ./nix/shell.nix {}; full = pkgs.callPackage ./nix/shell.nix {full = true;}; }; + packages.default = package; apps = { default = acmcsuf-api; acmcsuf-api = acmcsuf-api; - acmcsuf-cli = { - type = "app"; - program = "${package}/bin/acmcsuf-cli"; - }; + acmcsuf-cli = acmcsuf-cli; }; } ); From 8e6adf0413d71884356b7cf5ad6de5839ae8d17e Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 9 Mar 2026 09:27:44 -0700 Subject: [PATCH 06/10] update vendorhash --- nix/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/package.nix b/nix/package.nix index bc7f9fd6..7e19f82c 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -7,7 +7,7 @@ buildGoModule { name = "acmcsuf-api"; src = ../.; version = version; - vendorHash = "sha256-qr5wgHUKVv+Sv7TQGgOX9zRx9O6OgqFA16xwBTSysb4="; + vendorHash = "sha256-XCzKPPjCbO2Kp9XGZ94PpPedyJhFAs+ys+gna66jDSE="; subPackages = ["cmd/acmcsuf-api" "cmd/acmcsuf-cli"]; ldflags = ["-X main.Version=${version}"]; From dc3ba1fc7d88fa99326a5175ba6fe1828ec618e5 Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 9 Mar 2026 10:02:04 -0700 Subject: [PATCH 07/10] add ci dev shell --- flake.nix | 1 + nix/shell.nix | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index b94ee02c..ba0c5d84 100644 --- a/flake.nix +++ b/flake.nix @@ -35,6 +35,7 @@ devShells = { default = pkgs.callPackage ./nix/shell.nix {}; full = pkgs.callPackage ./nix/shell.nix {full = true;}; + ci = pkgs.callPackage ./nix/shell.nix {isCI = true;}; }; packages.default = package; diff --git a/nix/shell.nix b/nix/shell.nix index c0747a2b..315cfba7 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -15,6 +15,7 @@ go-migrate, sqlite, sqlite-web, + isCI ? false, full ? false, }: let go-migrate-sqlite = go-migrate.overrideAttrs (oldAttrs: { @@ -27,23 +28,26 @@ in go gopls # Go language server go-tools - delve # Go debugger sqlc # compiles SQL queries to Go code - air # run dev server with hot reload sqlfluff # SQL linter gnumake - xh go-swag - cobra-cli + ] + # Dev tools not required in CI go here + ++ lib.optionals (!isCI) [ + air # run dev server with hot reload + xh go-migrate-sqlite sqlite + cobra-cli + delve # Go debugger ] + # Heavyweight or rarely used tools go here ++ lib.optionals full [ - # Heavyweight/optional dependencies sqlite-web ]; - shellHook = '' + shellHook = lib.optionalString (!isCI) '' if [ ! -f .env ]; then echo ".env file not found! Creating one from .env.example for you..." cp .env.example .env From 3005d22b932230c887812d81de24c8600b98d2bc Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 9 Mar 2026 10:20:36 -0700 Subject: [PATCH 08/10] have ci use ci devshell --- .github/workflows/ci.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7df5b883..ac43748f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -31,24 +31,24 @@ jobs: - name: Format check if: steps.filter.outputs.source_code == 'true' - run: nix develop -c bash -c "make fmt && git diff --exit-code" + run: nix develop .#ci -c bash -c "make fmt && git diff --exit-code" - name: Check if: steps.filter.outputs.source_code == 'true' - run: nix develop -c make check + run: nix develop .#ci -c make check - name: Sql check if: steps.filter.outputs.source_code == 'true' - run: nix develop -c make check-sql + run: nix develop .#ci -c make check-sql - name: Build if: steps.filter.outputs.source_code == 'true' - run: nix develop -c make build + run: nix develop .#ci -c make build - - name: Generated Files check + - name: Generated files check if: steps.filter.outputs.source_code == 'true' - run: nix develop -c bash -c "make generate && git diff --exit-code" + run: nix develop .#ci -c bash -c "make generate && git diff --exit-code" - name: Test if: steps.filter.outputs.source_code == 'true' - run: nix develop -c make test + run: nix develop .#ci -c make test From aa20a0cc6807338bb4c7031d5da84abeff42fc8e Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 9 Mar 2026 10:21:49 -0700 Subject: [PATCH 09/10] use pname --- nix/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/package.nix b/nix/package.nix index 7e19f82c..3a15c393 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -4,7 +4,7 @@ buildGoModule, }: buildGoModule { - name = "acmcsuf-api"; + pname = "acmcsuf-api"; src = ../.; version = version; vendorHash = "sha256-XCzKPPjCbO2Kp9XGZ94PpPedyJhFAs+ys+gna66jDSE="; From 5d43e06cf899919992298d8c5b723b5205dc01a9 Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 9 Mar 2026 10:52:26 -0700 Subject: [PATCH 10/10] re-add goroot --- nix/shell.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nix/shell.nix b/nix/shell.nix index 315cfba7..72a24342 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -47,6 +47,10 @@ in sqlite-web ]; + env = { + GOROOT = "${go}/share/go"; + }; + shellHook = lib.optionalString (!isCI) '' if [ ! -f .env ]; then echo ".env file not found! Creating one from .env.example for you..."