nixfiles/hosts/hetzner-arm/profiles/photoprism.nix

84 lines
2.1 KiB
Nix
Raw Normal View History

2024-12-16 14:21:37 +00:00
{lib, config, pkgs, ...}: let
inherit (config.services.secrets) secrets;
rclonePhotos = pkgs.writeShellScriptBin "rclone-photos" ''
${pkgs.rclone}/bin/rclone --config ${secrets.photos_rclone_config.path} "$@"
'';
mountPhotos = pkgs.writeShellScriptBin "mount-photos" ''
umount -flR /Photos || true
${rclonePhotos}/bin/rclone-photos mount Photos: /Photos \
--allow-other \
--uid=${toString config.users.users.photoprism.uid} \
--gid=${toString config.users.groups.photoprism.gid} \
--umask=666 \
--cache-dir=/PhotosCache \
2024-12-16 14:27:55 +00:00
--dir-cache-time=10m \
2024-12-16 14:21:37 +00:00
--vfs-cache-mode=full \
2024-12-16 14:27:55 +00:00
--vfs-cache-max-size=2g \
--vfs-cache-max-age=10m \
2024-12-16 14:21:37 +00:00
--log-level=INFO "$@"
'';
inherit (lib.modules) mkMerge mkForce;
inherit (builtins) toFile;
in {
environment.systemPackages = with pkgs; [
rclone
rclonePhotos
fuse
fuse3
mountPhotos
2024-12-16 14:27:55 +00:00
util-linux
2024-12-16 14:21:37 +00:00
];
systemd.tmpfiles.rules = [
2024-12-16 14:37:23 +00:00
"d /PhotosCache - photoprism photoprism"
"d /Photos - photoprism photoprism"
2024-12-16 14:21:37 +00:00
];
users.users.photoprism = {
isSystemUser = true;
uid = 1290;
group = "photoprism";
};
users.groups.photoprism.gid = 1290;
2024-12-16 13:49:39 +00:00
services.photoprism = {
enable = true;
2024-12-16 14:21:37 +00:00
originalsPath = "/Photos";
2024-12-16 14:48:23 +00:00
settings = {
2024-12-16 14:47:50 +00:00
PHOTOPRISM_SITE_URL = "https://photoprism.owo.monster";
2024-12-16 14:53:00 +00:00
PHOTOPRISM_ADMIN_PASSWORD = "admin";
2024-12-16 14:47:50 +00:00
};
2024-12-16 13:49:39 +00:00
};
2024-12-16 14:40:52 +00:00
services.nginx.virtualHosts."photoprism.owo.monster" = {
2024-12-16 13:49:39 +00:00
forceSSL = true;
enableACME = true;
locations = {
"/" = {
2024-12-16 14:41:42 +00:00
proxyPass = "http://127.0.0.1:${toString config.services.photoprism.port}";
2024-12-16 13:49:39 +00:00
proxyWebsockets = true;
extraConfig = ''
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_buffering off;
'';
};
};
};
2024-12-16 14:21:37 +00:00
programs.fuse.userAllowOther = true;
systemd.services.photos-mount = {
wantedBy = ["photoprism.service"];
partOf = ["photoprism.service"];
path = with pkgs; [
fuse
fuse3
2024-12-16 14:27:55 +00:00
util-linux
2024-12-16 14:21:37 +00:00
];
serviceConfig.ExecStart = "${mountPhotos}/bin/mount-photos --syslog";
};
}