Files
Gebos/nix/modules/gebos-supabase.nix
T
Klaus 2dd5ed5877
check / flake-check (pull_request) Has been cancelled
Add sops-nix secrets + dev defaults so local stack runs with zero setup
- 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).
2026-05-30 00:17:13 +00:00

64 lines
2.0 KiB
Nix

{ config, lib, pkgs, ... }:
let
cfg = config.services.gebos.supabase;
composeDir = ../supabase;
in
{
options.services.gebos.supabase = {
enable = lib.mkEnableOption "Supabase stack via vanilla docker-compose";
postgresHost = lib.mkOption {
type = lib.types.str;
description = "External Postgres host (db-host).";
};
postgresPort = lib.mkOption {
type = lib.types.port;
default = 5432;
};
studioBindAddress = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = "Studio is intentionally never exposed publicly.";
};
};
config = lib.mkIf cfg.enable {
virtualisation.docker.enable = true;
systemd.tmpfiles.rules = [
"d /var/lib/gebos-supabase 0750 root root - -"
];
# Copy the vendored compose file into place at activation time so changes
# to nix/supabase/docker-compose.yml are deployed atomically.
environment.etc."gebos/supabase/docker-compose.yml".source =
"${composeDir}/docker-compose.yml";
systemd.services.gebos-supabase = {
description = "Gebos — Supabase compose stack";
after = [ "docker.service" "network-online.target" ];
wants = [ "docker.service" "network-online.target" ];
wantedBy = [ "multi-user.target" ];
environment = {
POSTGRES_HOST = cfg.postgresHost;
POSTGRES_PORT = toString cfg.postgresPort;
POSTGRES_DB = "postgres";
STUDIO_BIND = cfg.studioBindAddress;
};
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
WorkingDirectory = "/etc/gebos/supabase";
# POSTGRES_PASSWORD, JWT_SECRET, ANON_KEY, SERVICE_ROLE_KEY, DASHBOARD_PASSWORD.
# Rendered by sops-nix from nix/secrets/secrets.yaml — see gebos-secrets module.
EnvironmentFile = config.services.gebos.secrets.envFile;
ExecStart = "${pkgs.docker}/bin/docker compose up -d --remove-orphans";
ExecStop = "${pkgs.docker}/bin/docker compose down";
};
};
};
}