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"
];
};
}

View file

@ -31,6 +31,7 @@ inputs.nixpkgs.lib.nixosSystem {
../../configs/nixos/miniserve-tmp-upload.nix
../../configs/nixos/minecraft-docker.nix
../../configs/nixos/nginx-static.nix
../../configs/nixos/immich.nix
({
config,
pkgs,

View file

@ -69,6 +69,14 @@
mountpoint = "/storage";
};
datasets = {
database={
type = "zfs_fs";
options = {
mountpoint ="/postgres";
recordsize = "8K";
primarycache="metadata";
};
};
backup = {
type = "zfs_fs";
options = {

View file

@ -50,6 +50,11 @@
type = lib.types.listOf lib.types.path;
description = "paths to back up.";
};
user = lib.mkOption {
type = lib.types.str;
description = "what user to run the backup under.";
default = "root";
};
preBackupCommands = lib.mkOption {
type = lib.types.nullOr lib.types.lines;
description = "commands to run before the start of the backup.";
@ -139,6 +144,7 @@
backupPrepareCommand = backup.preBackupCommands;
backupCleanupCommand = backup.postBackupCommands;
paths = backup.paths;
user = backup.user;
}
)
cfg.backups