Compare commits

...

2 commits

Author SHA1 Message Date
Antoine Martin e7c479d433 hades: enable photoprism 2022-10-11 21:37:23 +02:00
Antoine Martin 849a8866d6 services: photoprism: init 2022-10-11 21:36:27 +02:00
3 changed files with 90 additions and 0 deletions

View file

@ -73,6 +73,11 @@ in {
privatePort = 8080; privatePort = 8080;
}; };
photoprism = {
enable = true;
port = 8084;
};
restic-backup = { restic-backup = {
enable = true; enable = true;
repo = "b2:hades-backup-alarsyo"; repo = "b2:hades-backup-alarsyo";

View file

@ -14,6 +14,7 @@
./nextcloud.nix ./nextcloud.nix
./nginx.nix ./nginx.nix
./paperless.nix ./paperless.nix
./photoprism.nix
./pipewire.nix ./pipewire.nix
./postgresql-backup.nix ./postgresql-backup.nix
./postgresql.nix ./postgresql.nix

84
services/photoprism.nix Normal file
View file

@ -0,0 +1,84 @@
{
config,
lib,
pkgs,
...
}: let
inherit
(lib)
mkEnableOption
mkIf
mkOption
;
cfg = config.my.services.photoprism;
my = config.my;
domain = config.networking.domain;
hostname = config.networking.hostName;
fqdn = "${hostname}.${domain}";
in {
options.my.services.photoprism = let
inherit (lib) types;
in {
enable = mkEnableOption "Photoprism config";
home = mkOption {
type = types.str;
default = "/var/lib/photoprism";
example = "/var/lib/photoprism";
description = "Home for the photoprism service, where data will be stored";
};
port = mkOption {
type = types.port;
default = 2342;
example = 8080;
description = "Internal port for Photoprism webapp";
};
};
config = mkIf cfg.enable {
users.users.photoprism = {
isSystemUser = true;
home = cfg.home;
createHome = true;
group = "photoprism";
};
users.groups.photoprism = {};
services.nginx.virtualHosts = {
"photoprism.${domain}" = {
forceSSL = true;
useACMEHost = fqdn;
listen = [
# FIXME: hardcoded tailscale IP
{
addr = "100.80.61.67";
port = 443;
ssl = true;
}
{
addr = "100.80.61.67";
port = 80;
ssl = false;
}
];
locations."/" = {
proxyPass = "http://127.0.0.1:${toString cfg.port}";
proxyWebsockets = true;
};
};
};
security.acme.certs.${fqdn}.extraDomainNames = ["photoprism.${domain}"];
my.services.restic-backup = mkIf cfg.enable {
paths = [
cfg.home
];
};
};
}