{ pkgs, lib, config, inputs, ... }: let server = pkgs.buildGoModule { pname = "metadata-agregator"; version = "0.1.0"; src = ./.; vendorHash = "sha256-iRG3hW7lQW1c9vIfpDs110AHeoq7N3KjyvJN9K0Sjos="; subPackages = [ "cmd/server" ]; }; in { languages.go.enable = true; git-hooks.hooks = { treefmt.enable = true; }; treefmt = { enable = true; config.programs = { nixfmt.enable = true; gofmt.enable = true; }; }; packages = with pkgs; [ pre-commit gitleaks plantuml gopls gotools go-tools golangci-lint buf protoc-gen-go protoc-gen-go-grpc grpcurl opencode ]; services.postgres = { enable = true; listen_addresses = "localhost"; initialDatabases = [ { name = "metadata_agregator"; schema = ./nix/schema/001_schema.sql; } ]; initialScript = '' CREATE USER agregator WITH PASSWORD 'agregator'; GRANT ALL PRIVILEGES ON DATABASE metadata_agregator TO agregator; \c metadata_agregator GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO agregator; GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO agregator; GRANT ALL ON SCHEMA public TO agregator; ''; }; processes.metadata-agregator = { exec = '' export DATABASE_URL="postgresql://agregator:agregator@localhost/metadata_agregator?host=${config.env.PGHOST}" cat > "$DEVENV_RUNTIME/metadata-config.yaml" <<'YAML' server: port: 50053 YAML ${config.outputs.server}/bin/server -config "$DEVENV_RUNTIME/metadata-config.yaml" ''; after = [ "devenv:processes:postgres" ]; # Probes the standard gRPC Health Checking Protocol (cmd/server/main.go # registers google.golang.org/grpc/health + reflection). Port matches # server.port in the YAML above. SERVING means the gRPC server is # accepting connections; postgres readiness is already gated by `after`. ready.exec = "grpcurl -plaintext -max-time 2 localhost:50053 grpc.health.v1.Health/Check | grep -q SERVING"; }; outputs = { inherit server; }; }