Restructure DB config, add ssh keys
This commit is contained in:
parent
9479490574
commit
8f8da2a071
|
@ -6,8 +6,7 @@
|
||||||
extraGroups = [ "wheel" ];
|
extraGroups = [ "wheel" ];
|
||||||
openssh.authorizedKeys.keys = [
|
openssh.authorizedKeys.keys = [
|
||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICO4LyBsW1YuUA6i3EL/IZhchSvk7reO4qgRmR/tdQPU emelie@flap"
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICO4LyBsW1YuUA6i3EL/IZhchSvk7reO4qgRmR/tdQPU emelie@flap"
|
||||||
"sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIFKHlANxRo9NEU6GHMCiAhv3Kxbxd6mOrOiMBw3bGohOAAAABHNzaDo= emelie@flap-fed"
|
"sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIGRtSxLRqPWmsn161ybDFcMYxrBKhay5a485tlM8hQEuAAAABHNzaDo= emelie@thinky-fed"
|
||||||
"sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIE7/U/Mk1jGofcommKmPfG+qwybiFH1nFkXzUqGiXSy/AAAABHNzaDo= emelie@thinky-fed"
|
|
||||||
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
./services/restic.nix
|
./services/restic.nix
|
||||||
./services/synapse.nix
|
./services/synapse.nix
|
||||||
./services/postgres.nix
|
./services/postgres.nix
|
||||||
|
#./services/mail.nix
|
||||||
|
#./services/containers.nix
|
||||||
|
#./services/redis.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
boot.loader.grub.enable = true;
|
boot.loader.grub.enable = true;
|
||||||
|
|
BIN
config/hosts/grondahl/data/secrets/authentik_env
Normal file
BIN
config/hosts/grondahl/data/secrets/authentik_env
Normal file
Binary file not shown.
Binary file not shown.
BIN
config/hosts/grondahl/data/secrets/mobilizon_env
Normal file
BIN
config/hosts/grondahl/data/secrets/mobilizon_env
Normal file
Binary file not shown.
Binary file not shown.
BIN
config/hosts/grondahl/data/secrets/synapse_db_password
Normal file
BIN
config/hosts/grondahl/data/secrets/synapse_db_password
Normal file
Binary file not shown.
53
config/hosts/grondahl/services/containers.nix
Normal file
53
config/hosts/grondahl/services/containers.nix
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
config.virtualisation.oci-containers = {
|
||||||
|
backend = "podman";
|
||||||
|
containers = {
|
||||||
|
#mobilizon = {
|
||||||
|
# image = "framasoft/mobilizon";
|
||||||
|
# ports = [ "127.0.0.1:4000:4000" ];
|
||||||
|
# volumes = [
|
||||||
|
# "/var/lib/mobilizon/uploads:/var/lib/mobilizon/uploads"
|
||||||
|
# "/run/postgresql/.s.PGSQL.5432:/run/postgresql/.s.PGSQL.5432"
|
||||||
|
# ];
|
||||||
|
# environmentFiles = [ config.secrets.files.mobilizon_env.file ];
|
||||||
|
# };
|
||||||
|
authentik-server = {
|
||||||
|
image = "ghcr.io/goauthentik/server:stable";
|
||||||
|
ports = [
|
||||||
|
"127.0.0.1:9000:9000"
|
||||||
|
"127.0.0.1:9443:9443"
|
||||||
|
];
|
||||||
|
volumes = [
|
||||||
|
"/var/lib/authentik/media:/media"
|
||||||
|
"/var/lib/authentik/templates:/templates"
|
||||||
|
"/run/postgresql/.s.PGSQL.5432:/run/postgresql/.s.PGSQL.5432"
|
||||||
|
"/run/redis/redis.sock:/run/redis/redis.sock"
|
||||||
|
];
|
||||||
|
environmentFiles = [ config.secrets.files.authentik_env.file ];
|
||||||
|
cmd = ["server"];
|
||||||
|
};
|
||||||
|
authentik-worker = {
|
||||||
|
image = "ghcr.io/goauthentik/server:stable";
|
||||||
|
volumes = [
|
||||||
|
"/var/lib/authentik/backups:/backups"
|
||||||
|
"/var/lib/authentik/media:/media"
|
||||||
|
"/var/lib/authentik/certs:/certs"
|
||||||
|
"/var/lib/authentik/templates:/templates"
|
||||||
|
];
|
||||||
|
environmentFiles = [ config.secrets.files.authentik_env.file ];
|
||||||
|
cmd = ["worker"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config.systemd.services.create-authentik-pod = with config.virtualisation.oci-containers; {
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
wantedBy = [ "podman-authentik-server.service" "podman-authentik-worker.service" ];
|
||||||
|
script = ''
|
||||||
|
${pkgs.podman}/bin/podman pod exists authentik || \
|
||||||
|
${pkgs.podman}/bin/podman pod create -n authentik -p '127.0.0.1:9000:9000' -p '127.0.0.1:9443:9443'
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
29
config/hosts/grondahl/services/mail.nix
Normal file
29
config/hosts/grondahl/services/mail.nix
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
(builtins.fetchTarball {
|
||||||
|
# Pick a commit from the branch you are interested in
|
||||||
|
url = "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/6e3a7b2ea6f0d68b82027b988aa25d3423787303/nixos-mailserver-6e3a7b2ea6f0d68b82027b988aa25d3423787303.tar.gz";
|
||||||
|
# And set its hash
|
||||||
|
sha256 = "1i56llz037x416bw698v8j6arvv622qc0vsycd20lx3yx8n77n44";
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
mailserver = {
|
||||||
|
enable = true;
|
||||||
|
fqdn = "anarkafem.dev";
|
||||||
|
domains = [ "anarkafem.dev" ];
|
||||||
|
|
||||||
|
# A list of all login accounts. To create the password hashes, use
|
||||||
|
# nix run nixpkgs.apacheHttpd -c htpasswd -nbB "" "super secret password" | cut -d: -f2
|
||||||
|
loginAccounts = {
|
||||||
|
"noreply@anarkafem.dev" = {
|
||||||
|
hashedPasswordFile = config.secrets.files.email_noreply.file;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
keyFile = config.security.acme.certs."anarkafem.dev".directory + "/key.pem";
|
||||||
|
certificateFile = config.security.acme.certs."anarkafem.dev".directory + "/cert.pem";
|
||||||
|
certificateScheme = 1;
|
||||||
|
};
|
||||||
|
}
|
|
@ -20,5 +20,15 @@
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
"cal.anarkafem.dev" = {
|
||||||
|
useACMEHost = "anarkafem.dev";
|
||||||
|
forceSSL = true;
|
||||||
|
locations."/".proxyPass = "http://127.0.0.1:4000";
|
||||||
|
};
|
||||||
|
"auth.anarkafem.dev" = {
|
||||||
|
useACMEHost = "anarkafem.dev";
|
||||||
|
forceSSL = true;
|
||||||
|
locations."/".proxyPass = "http://127.0.0.1:9000";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,55 @@
|
||||||
{ pkgs, ... }:
|
{ pkgs, config, ... }:
|
||||||
{
|
{
|
||||||
services.postgresql = {
|
services.postgresql = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.postgresql_13;
|
package = pkgs.postgresql_13;
|
||||||
|
extraPlugins = with config.services.postgresql.package.pkgs; [
|
||||||
|
postgis
|
||||||
|
];
|
||||||
|
ensureDatabases = [
|
||||||
|
"matrix-synapse"
|
||||||
|
"mobilizon"
|
||||||
|
"authentik"
|
||||||
|
];
|
||||||
|
ensureUsers = [
|
||||||
|
{
|
||||||
|
name = "matrix-synapse";
|
||||||
|
ensurePermissions."DATABASE \"matrix-synapse\"" = "ALL PRIVILEGES";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "mobilizon";
|
||||||
|
ensurePermissions."DATABASE mobilizon" = "ALL PRIVILEGES";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "authentik";
|
||||||
|
ensurePermissions."DATABASE authentik" = "ALL PRIVILEGES";
|
||||||
|
}
|
||||||
|
];
|
||||||
initialScript = pkgs.writeText "synapse-init.sql" ''
|
initialScript = pkgs.writeText "synapse-init.sql" ''
|
||||||
CREATE ROLE synapse;
|
CREATE ROLE matrix-synapse;
|
||||||
CREATE DATABASE synapse WITH OWNER synapse
|
CREATE DATABASE matrix-synapse WITH OWNER matrix-synapse
|
||||||
TEMPLATE template0
|
TEMPLATE template0
|
||||||
LC_COLLATE = "C"
|
LC_COLLATE = "C"
|
||||||
LC_CTYPE = "C"
|
LC_CTYPE = "C"
|
||||||
ENCODING = "UTF8";
|
ENCODING = "UTF8";
|
||||||
'';
|
'';
|
||||||
authentication = pkgs.lib.mkOverride 10 ''
|
settings = { password_encryption = "scram-sha-256"; };
|
||||||
local all all trust
|
authentication = pkgs.lib.mkForce ''
|
||||||
host all all ::1/128 trust
|
local all postgres peer
|
||||||
|
local all matrix-synapse peer
|
||||||
|
local all mobilizon scram-sha-256
|
||||||
|
local all authentik scram-sha-256
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
services.postgresqlBackup = {
|
services.postgresqlBackup = {
|
||||||
enable = true;
|
enable = true;
|
||||||
location = "/var/lib/postgresql/backup";
|
location = "/var/lib/postgresql/backup";
|
||||||
databases = [ "synapse" ];
|
databases = [
|
||||||
|
"matrix-synapse"
|
||||||
|
"mobilizon"
|
||||||
|
"authentik"
|
||||||
|
];
|
||||||
startAt = "02:30";
|
startAt = "02:30";
|
||||||
compression = "none";
|
compression = "none";
|
||||||
};
|
};
|
||||||
|
|
11
config/hosts/grondahl/services/redis.nix
Normal file
11
config/hosts/grondahl/services/redis.nix
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
services.redis = {
|
||||||
|
enable = true;
|
||||||
|
unixSocket = "/run/redis/redis.sock";
|
||||||
|
vmOverCommit = true;
|
||||||
|
unixSocketPerm = 770;
|
||||||
|
#requirePassfile = config.secrets.files.redis_pass.file;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -9,8 +9,9 @@
|
||||||
turn_shared_secret = builtins.toString config.secrets.files.turn_shared_secret.file;
|
turn_shared_secret = builtins.toString config.secrets.files.turn_shared_secret.file;
|
||||||
max_upload_size = "100M";
|
max_upload_size = "100M";
|
||||||
database_type = "psycopg2";
|
database_type = "psycopg2";
|
||||||
database_user = "synapse";
|
database_args = {
|
||||||
database_name = "synapse";
|
password = builtins.toString config.secrets.files.synapse_db_password.file;
|
||||||
|
};
|
||||||
turn_uris = [
|
turn_uris = [
|
||||||
"turn:turn.anarkafem.dev:3478?transport=udp"
|
"turn:turn.anarkafem.dev:3478?transport=udp"
|
||||||
"turn:turn.anarkafem.dev:3478?transport=tcp"
|
"turn:turn.anarkafem.dev:3478?transport=tcp"
|
||||||
|
|
|
@ -2,9 +2,12 @@
|
||||||
{
|
{
|
||||||
services.postgresql = {
|
services.postgresql = {
|
||||||
enable = true;
|
enable = true;
|
||||||
ensureDatabases = [ "nextcloud" ];
|
ensureDatabases = [
|
||||||
|
"nextcloud"
|
||||||
|
];
|
||||||
ensureUsers = [
|
ensureUsers = [
|
||||||
{ name = "nextcloud";
|
{
|
||||||
|
name = "nextcloud";
|
||||||
ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES";
|
ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -13,7 +16,7 @@
|
||||||
services.postgresqlBackup = {
|
services.postgresqlBackup = {
|
||||||
enable = true;
|
enable = true;
|
||||||
location = "/var/lib/postgresql/backup";
|
location = "/var/lib/postgresql/backup";
|
||||||
databases = [ "synapse" ];
|
databases = [ "nextcloud" ];
|
||||||
startAt = "02:30";
|
startAt = "02:30";
|
||||||
compression = "none";
|
compression = "none";
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue