nixos/modules/services/photoprism.nix

57 lines
1.9 KiB
Nix
Raw Normal View History

2023-10-04 11:06:37 +08:00
inputs:
{
options.nixos.services.photoprism = let inherit (inputs.lib) mkOption types; in
{
enable = mkOption { type = types.bool; default = false; };
2023-11-12 17:29:40 +08:00
hostname = mkOption { type = types.nonEmptyStr; default = "photoprism.chn.moe"; };
2023-10-04 11:06:37 +08:00
port = mkOption { type = types.ints.unsigned; default = 2342; };
};
config =
let
inherit (inputs.lib) mkIf;
inherit (inputs.config.nixos.services) photoprism;
in mkIf photoprism.enable
{
services.photoprism =
{
enable = true;
originalsPath = inputs.config.services.photoprism.storagePath + "/originals";
settings =
{
PHOTOPRISM_SITE_URL = "https://${photoprism.hostname}";
PHOTOPRISM_HTTP_PORT = "${toString photoprism.port}";
PHOTOPRISM_DISABLE_TLS = "true";
PHOTOPRISM_DETECT_NSFW = "true";
PHOTOPRISM_UPLOAD_NSFW = "true";
PHOTOPRISM_DATABASE_DRIVER = "mysql";
PHOTOPRISM_DATABASE_SERVER = "127.0.0.1:3306";
};
};
systemd.services.photoprism =
{
after = [ "mariadb.service" ];
requires = [ "mariadb.service" ];
serviceConfig.EnvironmentFile = inputs.config.sops.templates."photoprism/env".path;
};
sops =
{
templates."photoprism/env".content = let placeholder = inputs.config.sops.placeholder; in
''
PHOTOPRISM_ADMIN_PASSWORD=${placeholder."photoprism/adminPassword"}
PHOTOPRISM_DATABASE_PASSWORD=${placeholder."mariadb/photoprism"}
'';
secrets."photoprism/adminPassword" = {};
};
2023-11-09 20:43:25 +08:00
nixos.services =
{
mariadb = { enable = true; instances.photoprism = {}; };
nginx =
{
enable = true;
2023-11-09 22:19:37 +08:00
https.${photoprism.hostname}.location."/".proxy =
2023-11-16 15:51:47 +08:00
{ upstream = "http://127.0.0.1:${toString photoprism.port}"; websocket = true; };
2023-11-09 20:43:25 +08:00
};
};
2023-10-04 11:06:37 +08:00
};
}