Add sops-nix secrets + dev defaults so local stack runs with zero setup
check / flake-check (pull_request) Has been cancelled

- sops-nix flake input, age + ssh-to-age in devShell, .sops.yaml with
  per-host recipients (real pubkeys still TODO until lars bootstraps).
- nix/modules/gebos-secrets.nix centralises per-host secret subsets and
  renders /run/secrets/gebos-env via sops.templates. Service modules now
  read EnvironmentFile= from services.gebos.secrets.envFile instead of
  the placeholder /etc/gebos/secrets.env.
- Falls back to a writeText env file when nix/secrets/secrets.yaml is
  absent, so `nix flake check` and first-boot eval work pre-bootstrap.
- nix/secrets/README.md walks through age key + sops bootstrap.
- Dev defaults: ingester binary falls back to local tcp/postgres URLs,
  process-compose adds mosquitto and wires GEBOS_MQTT_BROKER /
  GEBOS_POSTGRES_URL / GEBOS_POSTGRES_PASSWORD + VITE_SUPABASE_URL /
  VITE_SUPABASE_ANON_KEY, frontend defaults to 127.0.0.1:8000 in DEV.

Refs #23 (comment #110).
This commit is contained in:
Klaus
2026-05-30 00:17:13 +00:00
parent 2d57db8182
commit 2dd5ed5877
17 changed files with 375 additions and 28 deletions
+35 -7
View File
@@ -15,13 +15,34 @@ import (
"syscall"
)
func main() {
broker := os.Getenv("GEBOS_MQTT_BROKER")
pgURL := os.Getenv("GEBOS_POSTGRES_URL")
pgPassword := os.Getenv("GEBOS_POSTGRES_PASSWORD")
// Defaults match the local dev stack in nix/dev/process-compose.nix so
// `go run ./ingester` works without any env setup. Prod always sets these
// explicitly via the systemd unit's EnvironmentFile.
const (
defaultBroker = "tcp://127.0.0.1:1883"
defaultPgURL = "postgres://gebos_ingest@127.0.0.1:5432/gebos?sslmode=disable"
defaultPgPassword = "dev"
)
if broker == "" || pgURL == "" || pgPassword == "" {
log.Fatal("GEBOS_MQTT_BROKER, GEBOS_POSTGRES_URL and GEBOS_POSTGRES_PASSWORD must be set")
func envOr(key, fallback string) (string, bool) {
if v := os.Getenv(key); v != "" {
return v, false
}
return fallback, true
}
func main() {
broker, brokerDefault := envOr("GEBOS_MQTT_BROKER", defaultBroker)
pgURL, pgURLDefault := envOr("GEBOS_POSTGRES_URL", defaultPgURL)
pgPassword, pgPasswordDefault := envOr("GEBOS_POSTGRES_PASSWORD", defaultPgPassword)
_ = pgPassword
if brokerDefault || pgURLDefault || pgPasswordDefault {
log.Printf("gebos-ingester: using dev defaults for: %s%s%s — set env vars in prod",
ifStr(brokerDefault, "GEBOS_MQTT_BROKER ", ""),
ifStr(pgURLDefault, "GEBOS_POSTGRES_URL ", ""),
ifStr(pgPasswordDefault, "GEBOS_POSTGRES_PASSWORD ", ""),
)
}
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
@@ -35,7 +56,14 @@ func main() {
// 4. batch with a short flush interval (50100ms) for throughput
// 5. shutdown on ctx.Done
log.Printf("gebos-ingester: broker=%s db=<redacted> (stub)", broker)
log.Printf("gebos-ingester: broker=%s db=%s (stub)", broker, pgURL)
<-ctx.Done()
log.Println("gebos-ingester: shutting down")
}
func ifStr(cond bool, a, b string) string {
if cond {
return a
}
return b
}