2024-12-25 23:32:02 +01:00
|
|
|
# self-hosted photo gallery
|
|
|
|
{ config, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.my.services.photos;
|
|
|
|
inherit (config.networking) domain;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.services.photos = {
|
2024-12-30 12:01:57 +01:00
|
|
|
enable = lib.mkEnableOption "Photos gallery";
|
2024-12-25 23:32:02 +01:00
|
|
|
|
|
|
|
secretsFile = lib.mkOption {
|
|
|
|
type = lib.types.nullOr lib.types.path;
|
|
|
|
default = null;
|
2024-12-30 12:01:57 +01:00
|
|
|
description = ''
|
2024-12-25 23:32:02 +01:00
|
|
|
pass secrets
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
port = lib.mkOption {
|
|
|
|
type = lib.types.port;
|
|
|
|
default = 2283;
|
2024-12-30 12:01:57 +01:00
|
|
|
description = ''
|
2024-12-25 23:32:02 +01:00
|
|
|
Web interface port.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = lib.mkOption {
|
|
|
|
type = lib.types.anything;
|
|
|
|
default = { };
|
|
|
|
description = ''
|
|
|
|
see <https://immich.app/docs/install/config-file/>.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
path = lib.mkOption {
|
|
|
|
type = lib.types.path;
|
|
|
|
default = null;
|
|
|
|
example = "/data/photos";
|
2024-12-30 12:01:57 +01:00
|
|
|
description = ''
|
2024-12-25 23:32:02 +01:00
|
|
|
Storage path of your original media files (photos and videos)
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.immich = {
|
|
|
|
enable = true;
|
|
|
|
# mediaLocation = path;
|
|
|
|
inherit (cfg)
|
|
|
|
secretsFile
|
|
|
|
port
|
|
|
|
;
|
|
|
|
settings = {
|
|
|
|
ffmpeg.transcode = "disabled";
|
|
|
|
server.externalDomain = "https://photos.${domain}";
|
|
|
|
} // cfg.settings;
|
|
|
|
environment = {
|
|
|
|
IMMICH_TELEMETRY_INCLUDE = "all";
|
|
|
|
IMMICH_API_METRICS_PORT = toString (cfg.port + 1);
|
|
|
|
IMMICH_MICROSERVICES_METRICS_PORT = toString (cfg.port + 2);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.prometheus = {
|
|
|
|
scrapeConfigs = [
|
|
|
|
{
|
|
|
|
job_name = "immich";
|
|
|
|
static_configs = [
|
|
|
|
{
|
2024-12-27 20:30:21 +01:00
|
|
|
targets = [ "localhost:${toString (cfg.port + 1)}" ];
|
2024-12-25 23:32:02 +01:00
|
|
|
labels = {
|
|
|
|
instance = config.networking.hostName;
|
|
|
|
service = "api";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
2024-12-27 20:30:21 +01:00
|
|
|
targets = [ "localhost:${toString (cfg.port + 2)}" ];
|
2024-12-25 23:32:02 +01:00
|
|
|
labels = {
|
|
|
|
instance = config.networking.hostName;
|
|
|
|
service = "server";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2025-01-26 00:34:16 +01:00
|
|
|
my.services.webserver.virtualHosts = [
|
2024-12-25 23:32:02 +01:00
|
|
|
{
|
|
|
|
subdomain = "photos";
|
|
|
|
inherit (cfg) port;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
webapps.apps.photos = {
|
|
|
|
dashboard = {
|
|
|
|
name = "Photos";
|
|
|
|
category = "media";
|
|
|
|
icon = "image";
|
|
|
|
url = "https://photos.${domain}";
|
|
|
|
method = "get";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|