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
2024-10-24 10:37:59 +02:00
mySQLPackage = pkgs . mariadb ;
2024-05-10 20:53:21 +02:00
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 ];
2024-10-12 18:24:32 +02:00
healthchecks . closed . public . ports . photoprism = [
photoprismPort
mysqlPort
] ;
2024-09-30 05:05:17 +02:00
healthchecks . http . photoprism = {
2024-09-16 02:06:03 +02:00
url = " h t t p : / / 1 0 . 1 0 0 . 0 . 1 : 2 3 4 2 / l i b r a r y / l o g i n " ;
expectedContent = " A I - P o w e r e d P h o t o s A p p " ;
} ;
2024-09-14 02:09:41 +02:00
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 } / m o n i t o r / c o n t a i n e r . n i x "
inputs . nix-topology . nixosModules . default
2024-10-18 02:26:27 +02:00
inputs . telemetry . nixosModules . telemetry
2024-08-31 18:28:34 +02:00
] ;
2024-08-29 03:26:04 +02:00
system . stateVersion = " 2 3 . 1 1 " ;
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 = " / v a r / l i b / p r i v a t e / p h o t o p r i s m / o r i g i n a l s " ;
address = " 0 . 0 . 0 . 0 " ;
settings = {
PHOTOPRISM_ADMIN_USER = " a d m i n " ;
PHOTOPRISM_ADMIN_PASSWORD = " . . . " ; # change me after initialisation
PHOTOPRISM_DEFAULT_LOCALE = " e n " ;
PHOTOPRISM_DATABASE_DRIVER = " m y s q l " ;
PHOTOPRISM_DATABASE_NAME = " p h o t o p r i s m " ;
PHOTOPRISM_DATABASE_SERVER = " / r u n / m y s q l d / m y s q l d . s o c k " ;
PHOTOPRISM_DATABASE_USER = " p h o t o p r i s m " ;
PHOTOPRISM_SITE_URL = " h t t p : / / p h o t o p r i s m . o r b i . p r i v a t e : ${ toString photoprismPort } " ;
PHOTOPRISM_SITE_TITLE = " P h o t o P r i s m " ;
PHOTOPRISM_UPLOAD_NSFW = " t r u e " ;
2024-09-14 03:52:00 +02:00
#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 = [ " p h o t o p r i s m " ] ;
ensureUsers = [
{
name = " p h o t o p r i s m " ;
ensurePermissions = {
" p h o t o p r i s m . * " = " A L L P R I V I L E G E S " ;
} ;
}
] ;
} ;
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
} ;
}