2023-09-27 21:24:23 +00:00
|
|
|
{ config, lib, pkgs, evalConfig, ... }:
|
2021-08-07 17:38:40 +00:00
|
|
|
|
|
|
|
{
|
2023-04-19 18:08:45 +00:00
|
|
|
|
|
|
|
sops.secrets = {
|
|
|
|
"hedgedoc-hacc/env" = {};
|
|
|
|
};
|
|
|
|
|
2021-08-07 18:27:04 +00:00
|
|
|
containers.pad-hacc = {
|
2021-08-07 17:38:40 +00:00
|
|
|
privateNetwork = true;
|
|
|
|
hostAddress = "192.168.100.1";
|
|
|
|
localAddress = "192.168.100.5";
|
|
|
|
autoStart = true;
|
|
|
|
bindMounts = {
|
|
|
|
"/persist" = {
|
|
|
|
hostPath = "/persist/containers/pad-hacc";
|
|
|
|
isReadOnly = false;
|
|
|
|
};
|
2023-04-19 18:08:45 +00:00
|
|
|
"/secrets".hostPath = "/run/secrets/hedgedoc-hacc";
|
2021-08-07 17:38:40 +00:00
|
|
|
};
|
2023-09-27 21:24:23 +00:00
|
|
|
path = evalConfig ({ config, lib, ... }: {
|
2021-08-07 17:38:40 +00:00
|
|
|
services.hedgedoc = {
|
|
|
|
enable = true;
|
2022-11-23 23:03:50 +00:00
|
|
|
settings = {
|
2021-08-07 17:38:40 +00:00
|
|
|
allowAnonymous = true;
|
|
|
|
allowFreeURL = true;
|
|
|
|
allowGravatar = false;
|
|
|
|
allowOrigin = [ "localhost" "pad.hacc.space" "fff-muc.de" ];
|
2022-01-12 18:33:07 +00:00
|
|
|
db = {
|
|
|
|
host = "/run/postgresql";
|
2022-01-27 20:20:25 +00:00
|
|
|
username = "codimd";
|
2022-01-12 18:33:07 +00:00
|
|
|
dialect = "postgres";
|
|
|
|
database = "codimd";
|
|
|
|
};
|
2021-08-07 17:38:40 +00:00
|
|
|
defaultPermission = "limited";
|
|
|
|
domain = "pad.hacc.space";
|
|
|
|
host = "0.0.0.0";
|
|
|
|
protocolUseSSL = true;
|
|
|
|
hsts.preload = false;
|
|
|
|
email = false;
|
|
|
|
oauth2 = {
|
2022-04-30 20:43:12 +00:00
|
|
|
authorizationURL = "https://login.infra4future.de/oauth2/authorize";
|
|
|
|
tokenURL = "https://login.infra4future.de/oauth2/token";
|
2021-08-07 17:38:40 +00:00
|
|
|
clientID = "hedgedoc";
|
2022-11-11 15:28:50 +00:00
|
|
|
# must be set to make the NixOS module happy, but env var takes precedence
|
|
|
|
clientSecret = "lol nope";
|
2021-08-07 17:38:40 +00:00
|
|
|
};
|
|
|
|
};
|
2023-04-19 18:08:45 +00:00
|
|
|
environmentFile = "/secrets/env";
|
2021-08-07 17:38:40 +00:00
|
|
|
};
|
|
|
|
systemd.services.hedgedoc.environment = {
|
2022-01-19 20:22:32 +00:00
|
|
|
"CMD_LOGLEVEL" = "warn";
|
2022-04-30 20:43:12 +00:00
|
|
|
"CMD_OAUTH2_USER_PROFILE_URL" = "https://login.infra4future.de/oauth2/userinfo";
|
|
|
|
"CMD_OAUTH2_USER_PROFILE_USERNAME_ATTR" = "nickname";
|
|
|
|
"CMD_OAUTH2_USER_PROFILE_DISPLAY_NAME_ATTR" = "name";
|
2021-08-07 17:38:40 +00:00
|
|
|
"CMD_OAUTH2_USER_PROFILE_EMAIL_ATTR" = "email";
|
|
|
|
"CMD_OAUTH2_PROVIDERNAME" = "Infra4Future";
|
|
|
|
};
|
2022-11-11 15:28:50 +00:00
|
|
|
|
2021-08-07 17:38:40 +00:00
|
|
|
services.postgresql = {
|
|
|
|
enable = true;
|
2021-08-07 18:27:04 +00:00
|
|
|
ensureDatabases = [ "codimd" ];
|
2021-08-07 17:38:40 +00:00
|
|
|
ensureUsers = [{
|
2021-08-07 18:27:04 +00:00
|
|
|
name = "codimd";
|
2023-11-30 16:43:48 +00:00
|
|
|
ensureDBOwnership = true;
|
2021-08-07 17:38:40 +00:00
|
|
|
}];
|
2022-01-12 22:59:48 +00:00
|
|
|
authentication = ''
|
|
|
|
local all all trust
|
2022-01-27 20:20:25 +00:00
|
|
|
host codimd codimd 127.0.0.1/32 trust
|
2022-01-12 22:59:48 +00:00
|
|
|
'';
|
2023-11-30 16:43:48 +00:00
|
|
|
package = pkgs.postgresql_15;
|
2021-08-07 17:38:40 +00:00
|
|
|
};
|
|
|
|
services.postgresqlBackup = {
|
|
|
|
enable = true;
|
2021-08-07 18:27:04 +00:00
|
|
|
databases = [ "codimd" ];
|
2021-08-07 17:38:40 +00:00
|
|
|
startAt = "*-*-* 23:45:00";
|
2021-08-07 18:27:04 +00:00
|
|
|
location = "/persist/backups/postgres";
|
2021-08-07 17:38:40 +00:00
|
|
|
};
|
2024-01-31 22:30:06 +00:00
|
|
|
hacc.bindToPersist = [ "/var/lib/hedgedoc" ];
|
2023-02-18 13:45:14 +00:00
|
|
|
});
|
2021-08-07 17:38:40 +00:00
|
|
|
};
|
|
|
|
services.nginx.virtualHosts."pad.hacc.earth" = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
globalRedirect = "pad.hacc.space";
|
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx.virtualHosts."pad.hacc.space" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
locations."/" = {
|
2021-08-07 18:27:04 +00:00
|
|
|
proxyPass = "http://${config.containers.pad-hacc.localAddress}:3000";
|
2021-08-07 17:38:40 +00:00
|
|
|
extraConfig = ''
|
|
|
|
add_header Access-Control-Allow-Origin "*";
|
|
|
|
proxy_buffering off;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|