infrastructure/nixos/hosts/olympus/dex/configuration.nix

107 lines
3.2 KiB
Nix
Raw Normal View History

2023-01-16 15:22:02 +01:00
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }:
let
vs = config.vault-secrets.secrets;
db_user = "dex";
db_name = "dex";
2023-05-05 10:04:38 +02:00
inherit (config.meta.exposes.dex) port;
2023-05-09 17:28:22 +02:00
metricsPort = 5558;
2023-11-10 23:41:30 +01:00
in {
2023-01-16 15:22:02 +01:00
imports = [ ];
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "23.05"; # Did you read the comment?
2023-05-09 17:28:22 +02:00
networking.firewall.allowedTCPPorts = [ port metricsPort ];
2023-01-16 15:22:02 +01:00
vault-secrets.secrets.dex = { };
2023-11-12 15:07:41 +01:00
vault-secrets.secrets.oauth2_proxy = { };
2023-01-16 15:22:02 +01:00
2023-11-10 23:41:30 +01:00
services = {
2023-01-16 15:22:02 +01:00
2023-11-10 23:41:30 +01:00
postgresql = {
enable = true;
package = pkgs.postgresql_15;
ensureDatabases = [ db_name ];
ensureUsers = [{
name = db_user;
ensurePermissions = {
"DATABASE ${db_name}" = "ALL PRIVILEGES";
"schema public" = "ALL";
2023-01-16 16:01:34 +01:00
};
}];
2023-01-16 15:22:02 +01:00
};
2023-11-10 23:41:30 +01:00
dex = {
enable = true;
settings = {
issuer = "https://dex.0x76.dev";
storage = {
type = "postgres";
config = {
host = "/var/run/postgresql";
user = db_user;
database = db_name;
};
2023-01-16 16:01:34 +01:00
};
2023-11-10 23:41:30 +01:00
web.http = "0.0.0.0:${toString port}";
telemetry.http = "0.0.0.0:${toString metricsPort}";
connectors = [{
type = "gitea";
id = "gitea";
name = "Gitea";
config = {
clientID = "$GITEA_CLIENT_ID";
clientSecret = "$GITEA_CLIENT_SECRET";
redirectURI = "https://dex.0x76.dev/callback";
baseURL = "https://git.0x76.dev";
};
}];
2023-11-09 15:36:53 +01:00
2023-11-10 23:41:30 +01:00
staticClients = [
{
id = "outline";
name = "Outline";
redirectURIs = [ "https://outline.0x76.dev/auth/oidc.callback" ];
secretEnv = "OUTLINE_CLIENT_SECRET";
}
{
id = "grafana";
name = "Grafana";
redirectURIs = [ "https://grafana.0x76.dev/login/generic_oauth" ];
secretEnv = "GRAFANA_CLIENT_SECRET";
}
{
id = "hedgedoc";
name = "Hedgedoc";
redirectURIs = [ "https://md.0x76.dev/auth/oauth2/callback" ];
secretEnv = "HEDGEDOC_CLIENT_SECRET";
}
{
id = "flux";
name = "Weave Gitops Flux Dashboard";
redirectURIs = [ "https://flux.0x76.dev/oauth2/callback" ];
secretEnv = "FLUX_CLIENT_SECRET";
}
{
2023-11-12 15:07:41 +01:00
id = "grist";
name = "grist";
redirectURIs = [ "https://grist.0x76.dev/oauth2/callback" ];
secretEnv = "GRIST_CLIENT_SECRET";
2023-11-10 23:41:30 +01:00
}
];
};
2023-11-09 15:36:53 +01:00
2023-11-10 23:41:30 +01:00
environmentFile = "${vs.dex}/environment";
};
2023-11-09 15:36:53 +01:00
};
2023-01-16 15:22:02 +01:00
}