snowfield/modules/docs/default.nix

54 lines
1.1 KiB
Nix
Raw Normal View History

2024-03-30 20:18:12 +01:00
{ lib, config, ... }:
2022-01-23 19:11:10 +01:00
with lib;
let
cfg = config.luj.docs;
port = 3013;
in
{
options.luj.docs = {
enable = mkEnableOption "activate hedgedoc service";
nginx.enable = mkEnableOption "activate nginx";
nginx.subdomain = mkOption { type = types.str; };
2022-01-23 19:11:10 +01:00
};
config = mkIf cfg.enable (mkMerge [
{
2022-01-23 19:11:10 +01:00
services.hedgedoc = {
enable = true;
2023-01-05 17:01:15 +01:00
settings = {
2024-03-30 20:21:59 +01:00
inherit port;
2022-01-23 19:11:10 +01:00
db = {
dialect = "postgres";
host = "/run/postgresql";
};
domain = "docs.julienmalka.me";
protocolUseSSL = true;
allowFreeURL = true;
allowEmailRegister = false;
allowAnonymous = false;
allowAnonymousEdits = true;
allowGravatar = true;
};
};
services.postgresql = {
2024-09-05 10:55:09 +02:00
enable = true;
2022-01-23 19:11:10 +01:00
ensureDatabases = [ "hedgedoc" ];
ensureUsers = [
{
name = "hedgedoc";
ensureDBOwnership = true;
2022-01-23 19:11:10 +01:00
}
];
};
}
(mkIf cfg.nginx.enable (mkSubdomain cfg.nginx.subdomain port))
2022-01-23 19:11:10 +01:00
(mkIf cfg.nginx.enable (mkVPNSubdomain cfg.nginx.subdomain port))
]);
2022-01-23 19:11:10 +01:00
}