68 lines
1.9 KiB
Nix
68 lines
1.9 KiB
Nix
{ config, lib, ... }:
|
|
with lib;
|
|
let
|
|
rootCfg = config.selfhosted;
|
|
common = rootCfg.common;
|
|
moduleCfg = rootCfg.immich;
|
|
cfg = moduleCfg.server;
|
|
hostDataPath = "${common.dataDir}/immich";
|
|
version = "v3.3.5";
|
|
in
|
|
{
|
|
imports = [ ./config.nix ];
|
|
|
|
options.selfhosted.immich.server = {
|
|
name = mkOption {
|
|
type = types.str;
|
|
};
|
|
hostHttpPort = mkOption {
|
|
type = types.port;
|
|
};
|
|
};
|
|
|
|
config = mkIf moduleCfg.enable {
|
|
virtualisation.oci-containers.containers."${cfg.name}" = {
|
|
image = "ghcr.io/immich-app/immich-server:${version}";
|
|
ports = [
|
|
"0.0.0.0:${toString cfg.hostHttpPort}:2283"
|
|
];
|
|
environmentFiles = [ config.sops.templates."immich.env".path ];
|
|
environment = {
|
|
IMMICH_VERSION = version;
|
|
DB_HOSTNAME = moduleCfg.postgresql.name;
|
|
DB_DATABASE_NAME = moduleCfg.postgresql.db;
|
|
DB_USERNAME = moduleCfg.postgresql.user;
|
|
REDIS_HOSTNAME = moduleCfg.redis.name;
|
|
};
|
|
volumes = [
|
|
"${hostDataPath}/data:/data"
|
|
"/etc/localtime:/etc/localtime:ro"
|
|
"${config.sops.templates."immich-config.json".path}:/app/immich-config.json/"
|
|
];
|
|
log-driver = "journald";
|
|
extraOptions = [
|
|
"--network=${common.network.name}"
|
|
];
|
|
};
|
|
|
|
systemd.services."${common.backend}-${cfg.name}" = {
|
|
serviceConfig = {
|
|
Restart = lib.mkOverride 90 "always";
|
|
};
|
|
wantedBy = [ "${common.backend}-${moduleCfg.targetName}.target" ];
|
|
partOf = [ "${common.backend}-${moduleCfg.targetName}.target" ];
|
|
requires = [
|
|
"${common.backend}-${moduleCfg.postgresql.name}.service"
|
|
"${common.backend}-${moduleCfg.redis.name}.service"
|
|
];
|
|
after = [
|
|
"${common.backend}-${moduleCfg.postgresql.name}.service"
|
|
"${common.backend}-${moduleCfg.redis.name}.service"
|
|
];
|
|
preStart = ''
|
|
mkdir -p ${hostDataPath}/data
|
|
'';
|
|
};
|
|
};
|
|
}
|