nixos-configs/configurations/nos/modules/docker/immich/compose.nix

126 lines
2.5 KiB
Nix
Raw Normal View History

2024-07-24 15:49:31 -04:00
{
config,
lib,
2024-07-24 15:49:31 -04:00
pkgs,
...
}: let
inherit (lib) attrValues;
inherit (config.sops) secrets;
2024-07-24 15:49:31 -04:00
inherit (config.khepri) rwDataDir;
2024-02-19 12:42:02 -05:00
rwPath = rwDataDir + "/immich";
UPLOAD_LOCATION = "${rwPath}/data";
synologyPath = "/var/lib/synology-immich";
2024-02-19 12:42:02 -05:00
in {
# NFS client setup
services.rpcbind.enable = true;
boot.supportedFilesystems = ["nfs"];
environment.systemPackages = attrValues {
inherit
(pkgs)
nfs-utils
immich-go # for uploading google photos
;
};
systemd.mounts = let
host = "10.0.0.117";
in [
{
type = "nfs";
mountConfig = {
Options = "noatime";
};
what = "${host}:/volume1/Photo-Immich";
where = synologyPath;
requiredBy = ["docker-immich_immich_server.service"];
}
];
# Docker compose
khepri.compositions."immich" = {
networks.proxy_net = {external = true;};
2024-02-19 12:42:02 -05:00
services = {
"immich_server" = {
image = import ./images/server.nix pkgs;
restart = "always";
environmentFiles = [
./env
secrets.immich.path
];
2024-02-19 12:42:02 -05:00
volumes = [
# "${synologyPath}:/usr/src/app/upload:rw"
"${UPLOAD_LOCATION}:/usr/src/app/upload:rw"
"${synologyPath}:${synologyPath}:rw"
];
ports = [
"2283:2283"
];
networks = ["proxy_net"];
2024-02-19 12:42:02 -05:00
dependsOn = ["immich_redis" "immich_postgres"];
2024-02-19 12:42:02 -05:00
environment.NODE_ENV = "production";
};
2024-02-19 12:42:02 -05:00
"immich_machine_learning" = {
image = import ./images/machine-learning.nix pkgs;
restart = "always";
environmentFiles = [
./env
secrets.immich.path
];
networks = ["proxy_net"];
2024-02-19 12:42:02 -05:00
volumes = [
"${rwPath}/cache:/cache"
];
};
"immich_redis" = {
image = import ./images/redis.nix pkgs;
restart = "always";
environmentFiles = [
./env
secrets.immich.path
];
networks = ["proxy_net"];
tmpfs = ["/data"];
};
2024-02-19 12:42:02 -05:00
"immich_postgres" = {
image = import ./images/postgres.nix pkgs;
restart = "always";
environmentFiles = [
./env
secrets.immich.path
];
networks = ["proxy_net"];
2024-02-19 12:42:02 -05:00
volumes = [
"${rwPath}/db:/var/lib/postgresql/data"
];
2024-02-19 12:42:02 -05:00
environment = {
POSTGRES_PASSWORD = "\${DB_PASSWORD}";
POSTGRES_USER = "\${DB_USERNAME}";
POSTGRES_DB = "\${DB_DATABASE_NAME}";
};
2024-02-19 12:42:02 -05:00
};
};
};
}