{ pkgs, config, ...}: let
  davesDomain = "syzygial.cc";
in {
  services.gitea = {
    enable = true;
    database = {
      type = "postgres";
      socket = "/run/postgresql";
    };
    settings = {
      server = {
        HTTP_PORT = 5000;
        ROOT_URL = "https://git.${davesDomain}";
      };
      actions = {
        ENABLED = true;
      };
    };
  };

  # Services Runner running in nixos-container w/ host label
  # This allows sharing of nix-store for caching actions builds
  # ... Maybe I'll actually set this up. Some concern for clearing its
  # cache and it overpopulating. Idk. We'll see.
  # services.gitea-actions-runner.instances."nix-runner" = {
  #   enable = true;
  #   name = "nix-runner";
  #   url = "http://localhost:${config.services.gitea.settings.server.HTTP_PORT}";
  #   labels = [
  #     # don't require docker/podman
  #     "native:host"
  #   ];
  #   tokenFile = "/var/lib/gitea/runner_token";
  # };
  
  services.postgresql = {
    enable = true;
    settings.port = 5432;
    ensureDatabases = [
      "gitea"
    ];
    ensureUsers = [{
      name = "gitea";
      ensureDBOwnership = true;
      ensureClauses = {
        createdb = true;
      };
    }];
  };
  services.caddy.virtualHosts = {
    "git.${davesDomain}" = {
	    extraConfig = ''
        reverse_proxy 127.0.0.1:${toString config.services.gitea.settings.server.HTTP_PORT}
      '';           
    };
  };
}
