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 ];
2024-09-14 02:09:41 +02:00
verify . closed . public . ports . photoprism = [ photoprismPort ] ;
2024-09-15 02:22:02 +02:00
verify . localCommands . photoprism =
let
domain = " 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 " ;
curl = lib . getExe pkgs . curl ;
grep = lib . getExe pkgs . gnugrep ;
grepString = " A I - P o w e r e d P h o t o s A p p " ;
in
''
if $ { curl } - s - o /dev/null - w " % { h t t p _ c o d e } " $ { domain } | $ { grep } - q " 2 0 0 " ; then
if $ { curl } - s $ { domain } | $ { grep } - q " ${ grepString } " ; then
echo " [ O K ] D i e S e i t e h a t S t a t u s c o d e 2 0 0 u n d e n t h ä l t d e n S t r i n g ' ${ grepString } ' . "
else
echo " [ F a i l ] D e r S t a t u s c o d e i s t 2 0 0 , a b e r d i e S e i t e e n t h ä l t d e n S t r i n g ' ${ grepString } ' n i c h t . "
fi
else
echo " [ F a i l ] D i e S e i t e h a t k e i n e n S t a t u s c o d e 2 0 0 . "
fi
'' ;
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-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
} ;
}