added immich to the homelab.

This commit is contained in:
Gabe Venberg 2025-05-03 22:26:25 +02:00
parent 478d5760bd
commit 11f6c18f13
5 changed files with 66 additions and 0 deletions

View file

@ -80,6 +80,14 @@ in {
description = "Movies";
};
}
{
Immich = {
icon = "sh-immich.svg";
href = "https://pics.venberg.xyz";
siteMonitor = "https://pics.venberg.xyz";
description = "Pictures";
};
}
{
Grocy = {
icon = "sh-grocy.svg";

43
configs/nixos/immich.nix Normal file
View file

@ -0,0 +1,43 @@
{
inputs,
config,
pkgs,
lib,
...
}: let
port = 2283;
cfg = config.services.immich;
backupPrepare = pkgs.writeShellScriptBin "postgres-immich-dump" ''
set -euxo pipefail
${lib.getExe pkgs.sudo} -iu postgres pg_dump -Fc immich > /backup/immich_psql.dump
'';
in {
# make sure your postgres database is on big storage, and if using zfs, create with the following settings:
# zfs create -o recordsize=8K -o primarycache=metadata -o mountpoint=/var/lib/postgresql <pool>/postgresql
services.immich = {
enable = true;
port = port;
machine-learning.enable = true;
mediaLocation = "/storage/immich";
settings = null;
};
imports = [
./nginx.nix
];
services.nginx.virtualHosts."pics.venberg.xyz" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
host.restic.backups.immich = {
preBackupCommands = lib.getExe backupPrepare;
paths = [
"/backup/immich_psql.dump"
"${cfg.mediaLocation}/library"
"${cfg.mediaLocation}/upload"
"${cfg.mediaLocation}/profile"
];
};
}