nixos/omnom: fix module

This commit is contained in:
eljamm 2025-05-20 21:02:36 +02:00 committed by Valentin Gagarin
parent 4e519da89e
commit 19c1b4250c

View File

@ -104,14 +104,6 @@ in
default = "fs";
description = "Storage type.";
};
root = lib.mkOption {
type = lib.types.path;
default = "${cfg.dataDir}/static/data";
defaultText = lib.literalExpression ''
"''${config.services.omnom.dataDir}/static/data"
'';
description = "Where the snapshots are saved.";
};
};
smtp = {
tls = lib.mkEnableOption "Whether TLS encryption should be used.";
@ -142,6 +134,24 @@ in
description = "Connection timeout duration in seconds.";
};
};
activitypub = {
pubkey = lib.mkOption {
type = lib.types.path;
default = "${cfg.dataDir}/public.pem";
defaultText = lib.literalExpression ''
"''${config.services.omnom.dataDir}/public.pem"
'';
description = "ActivityPub public key. Will be generated, by default.";
};
privkey = lib.mkOption {
type = lib.types.path;
default = "${cfg.dataDir}/private.pem";
defaultText = lib.literalExpression ''
"''${config.services.omnom.dataDir}/private.pem"
'';
description = "ActivityPub private key. Will be generated, by default.";
};
};
};
};
default = { };
@ -150,6 +160,13 @@ in
};
config = lib.mkIf cfg.enable {
services.omnom = {
settings.app = {
static_dir = "${cfg.dataDir}/static";
template_dir = "${cfg.package}/share/templates";
};
};
assertions = [
{
assertion = !lib.hasAttr "password" cfg.settings.smtp;
@ -157,16 +174,6 @@ in
`services.omnom.settings.smtp.password` must be defined in `services.omnom.passwordFile`.
'';
}
{
assertion = !(cfg.settings.storage.root != "${cfg.dataDir}/static/data");
message = ''
For Omnom to access the snapshots, it needs the storage root
directory to be inside the service's working directory.
As such, `services.omnom.settings.storage.root` must be the same as
`''${services.omnom.dataDir}/static/data`.
'';
}
];
systemd.services.omnom = {
@ -224,10 +231,10 @@ in
in
{
"${cfg.dataDir}"."d" = settings;
"${cfg.dataDir}/templates"."L+" = settings // {
argument = "${cfg.package}/share/templates";
"${cfg.settings.app.static_dir}"."C" = settings // {
argument = "${cfg.package}/share/static";
};
"${cfg.settings.storage.root}"."d" = settings;
"${cfg.settings.app.static_dir}/data"."d" = settings;
};
networking.firewall = lib.mkIf cfg.openFirewall {