Migrate Immich from Docker to the NixOS module
All checks were successful
/ test (push) Successful in -19s
All checks were successful
/ test (push) Successful in -19s
This commit is contained in:
parent
11618adc76
commit
65299f9f1f
2 changed files with 21 additions and 95 deletions
|
@ -1,99 +1,25 @@
|
|||
{ ... }:
|
||||
let
|
||||
vars = {
|
||||
serviceConfigRoot = "/mnt/hd/immich/state";
|
||||
mainArray = "/mnt/hd/immich/";
|
||||
domainName = "photos.aciceri.dev";
|
||||
};
|
||||
directories = [
|
||||
"${vars.serviceConfigRoot}/immich"
|
||||
"${vars.serviceConfigRoot}/immich/postgresql"
|
||||
"${vars.serviceConfigRoot}/immich/postgresql/data"
|
||||
"${vars.serviceConfigRoot}/immich/config"
|
||||
"${vars.serviceConfigRoot}/immich/machine-learning"
|
||||
"${vars.mainArray}/Photos"
|
||||
"${vars.mainArray}/Photos/Immich"
|
||||
"${vars.mainArray}/Photos/S10m"
|
||||
];
|
||||
in
|
||||
{ config, ... }:
|
||||
{
|
||||
systemd.tmpfiles.rules = map (x: "d ${x} 0775 root root - -") directories;
|
||||
systemd.services = {
|
||||
podman-immich = {
|
||||
requires = [
|
||||
"podman-immich-redis.service"
|
||||
"podman-immich-postgres.service"
|
||||
environment.persistence."/persist".directories = [
|
||||
config.services.immich.machine-learning.environment.MACHINE_LEARNING_CACHE_FOLDER
|
||||
];
|
||||
after = [
|
||||
"podman-immich-redis.service"
|
||||
"podman-immich-postgres.service"
|
||||
];
|
||||
};
|
||||
podman-immich-postgres = {
|
||||
requires = [ "podman-immich-redis.service" ];
|
||||
after = [ "podman-immich-redis.service" ];
|
||||
};
|
||||
|
||||
services.immich = {
|
||||
enable = true;
|
||||
mediaLocation = "/mnt/hd/immich";
|
||||
};
|
||||
|
||||
virtualisation.oci-containers.containers = {
|
||||
immich = {
|
||||
autoStart = true;
|
||||
image = "ghcr.io/imagegenius/immich:latest";
|
||||
volumes = [
|
||||
"${vars.serviceConfigRoot}/immich/config:/config"
|
||||
"${vars.mainArray}/Photos/Immich:/photos"
|
||||
"${vars.mainArray}/Photos/S10m:/import:ro"
|
||||
"${vars.serviceConfigRoot}/immich/machine-learning:/config/machine-learning"
|
||||
];
|
||||
# environmentFiles = [ config.age.secrets.ariaImmichDatabase.path ];
|
||||
environment = {
|
||||
PUID = "994";
|
||||
PGID = "993";
|
||||
TZ = "Europe/Rome";
|
||||
DB_HOSTNAME = "immich-postgres";
|
||||
DB_USERNAME = "immich";
|
||||
DB_DATABASE_NAME = "immich";
|
||||
REDIS_HOSTNAME = "immich-redis";
|
||||
DB_PASSWORD = "password";
|
||||
};
|
||||
extraOptions = [
|
||||
"--pull=newer"
|
||||
"--network=container:immich-redis"
|
||||
];
|
||||
};
|
||||
|
||||
immich-redis = {
|
||||
autoStart = true;
|
||||
image = "redis";
|
||||
extraOptions = [
|
||||
"--pull=newer"
|
||||
"-l=traefik.enable=true"
|
||||
"-l=traefik.http.routers.immich.rule=Host(`photos.${vars.domainName}`)"
|
||||
"-l=traefik.http.routers.immich.service=immich"
|
||||
"-l=traefik.http.services.immich.loadbalancer.server.port=8080"
|
||||
];
|
||||
ports = [
|
||||
"8080:8080"
|
||||
];
|
||||
};
|
||||
|
||||
immich-postgres = {
|
||||
autoStart = true;
|
||||
image = "tensorchord/pgvecto-rs:pg14-v0.2.1";
|
||||
volumes = [
|
||||
"${vars.serviceConfigRoot}/immich/postgresql/data:/var/lib/postgresql/data"
|
||||
];
|
||||
# environmentFiles = [ config.age.secrets.ariaImmichDatabase.path ];
|
||||
environment = {
|
||||
POSTGRES_USER = "immich";
|
||||
POSTGRES_DB = "immich";
|
||||
POSTGRES_HOST_AUTH_METHOD = "trust";
|
||||
POSTGRES_PASSWORD = "password";
|
||||
};
|
||||
extraOptions = [
|
||||
"--pull=newer"
|
||||
"--network=container:immich-redis"
|
||||
];
|
||||
};
|
||||
# The reason for this hack is quite bad
|
||||
# Before using the NixOS module Immich was installed using Docker, for this
|
||||
# reason the paths of the images in the database looks like `/photos/...`
|
||||
# and after migrating to the NixOS module I kept getting 404s for all the
|
||||
# old pictures.
|
||||
# Frankly it seems weird that it saved the absolute paths in the DB, perhaps
|
||||
# it saves somewhere else the media location root and then merge the paths,
|
||||
# however, nevertheless I set `mediaLocation` it didn't work
|
||||
fileSystems."/photos" = {
|
||||
device = "/mnt/hd/immich/";
|
||||
fsType = "ext4";
|
||||
options = [ "bind" ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
forceSSL = true;
|
||||
enableACME = true;
|
||||
locations."/" = {
|
||||
proxyPass = "http://localhost:8080";
|
||||
proxyPass = "http://localhost:${builtins.toString config.services.immich.port}";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue