nixos-config/machines/orbi/service-photoprism.nix

96 lines
2.8 KiB
Nix
Raw Normal View History

2024-08-29 03:26:04 +02:00
{
config,
pkgs,
lib,
components,
2024-08-31 18:28:34 +02:00
inputs,
2024-08-29 03:26:04 +02:00
...
}:
2024-05-10 20:53:21 +02:00
let
mySQLPackage = pkgs.mysql;
photoprismPort = 2342;
mysqlPort = 3336;
in
{
2024-05-10 23:17:45 +02:00
networking.firewall.interfaces.wg0.allowedTCPPorts = [ photoprismPort ];
# networking.firewall.interfaces.wg0.allowedUDPPorts = [ photoprismPort ];
healthchecks.closed.public.ports.photoprism = [ photoprismPort ];
healthchecks.http.photoprism = {
2024-09-16 02:06:03 +02:00
url = "http://10.100.0.1:2342/library/login";
expectedContent = "AI-Powered Photos App";
};
2024-05-10 20:53:21 +02:00
containers.photoprism = {
privateNetwork = false;
autoStart = true;
2024-08-29 03:26:04 +02:00
config =
{ config, lib, ... }:
{
nixpkgs.pkgs = pkgs;
2024-08-31 18:28:34 +02:00
imports = [
"${components}/monitor/container.nix"
inputs.nix-topology.nixosModules.default
];
2024-08-29 03:26:04 +02:00
system.stateVersion = "23.11";
services.logrotate.checkConfig = false; # because uid 3000 does not exist in here
2024-05-10 20:53:21 +02:00
2024-08-29 03:26:04 +02:00
environment.systemPackages = [
config.services.photoprism.package
];
2024-08-23 07:51:07 +02:00
2024-08-29 03:26:04 +02:00
# Photoprism
# ----------
services.photoprism = {
enable = true;
port = photoprismPort;
package = pkgs.legacy_2405.photoprism;
originalsPath = "/var/lib/private/photoprism/originals";
address = "0.0.0.0";
settings = {
PHOTOPRISM_ADMIN_USER = "admin";
PHOTOPRISM_ADMIN_PASSWORD = "..."; # change me after initialisation
PHOTOPRISM_DEFAULT_LOCALE = "en";
PHOTOPRISM_DATABASE_DRIVER = "mysql";
PHOTOPRISM_DATABASE_NAME = "photoprism";
PHOTOPRISM_DATABASE_SERVER = "/run/mysqld/mysqld.sock";
PHOTOPRISM_DATABASE_USER = "photoprism";
PHOTOPRISM_SITE_URL = "http://photoprism.orbi.private:${toString photoprismPort}";
PHOTOPRISM_SITE_TITLE = "PhotoPrism";
PHOTOPRISM_UPLOAD_NSFW = "true";
#PHOTOPRISM_THUMB_UNCACHED = "false"; # https://docs.photoprism.app/user-guide/settings/advanced/#static-and-dynamic-size-limits < prevents thumbs from beeing wrong orientation, but takes time for photo import.
2024-08-29 03:26:04 +02:00
};
2024-05-10 20:53:21 +02:00
};
2024-08-29 03:26:04 +02:00
# MySQL Database
# --------------
services.mysql = {
enable = true;
package = mySQLPackage;
settings.mysqld.port = mysqlPort;
ensureDatabases = [ "photoprism" ];
ensureUsers = [
{
name = "photoprism";
ensurePermissions = {
"photoprism.*" = "ALL PRIVILEGES";
};
}
];
};
2024-05-10 20:53:21 +02:00
2024-08-29 03:26:04 +02:00
# Backup Database
# ---------------
services.mysqlBackup = {
enable = true;
databases = config.services.mysql.ensureDatabases;
singleTransaction = true;
};
2024-05-10 20:53:21 +02:00
2024-08-29 03:26:04 +02:00
};
2024-05-10 20:53:21 +02:00
};
}