diff --git a/flake.nix b/flake.nix index 7c1ef49..48ad730 100644 --- a/flake.nix +++ b/flake.nix @@ -259,6 +259,7 @@ notifications = "ntfy.${baseName}"; prometheus = "prom.${baseName}"; paperless = "paper.${baseName}"; + photos = "photos.${baseName}"; secrets = "vault.${baseName}"; stream = "stream.${baseName}"; content = "cloud.${baseName}"; diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index ec3eda2..ffbac28 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -109,6 +109,7 @@ inputs.nixpkgs.lib.nixosSystem rec { services.audiobookshelf.enable = true; services.bind.enable = true; services.caddy.enable = true; + services.immich.enable = true; services.jellyfin.enable = true; services.nextcloud.enable = true; services.calibre-web.enable = true; diff --git a/modules/common/default.nix b/modules/common/default.nix index 455d3b9..e64492e 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -101,6 +101,10 @@ type = lib.types.str; description = "Hostname for document server (paperless-ngx)."; }; + photos = lib.mkOption { + type = lib.types.str; + description = "Hostname for photo management (Immich)."; + }; prometheus = lib.mkOption { type = lib.types.str; description = "Hostname for Prometheus server."; diff --git a/modules/nixos/services/default.nix b/modules/nixos/services/default.nix index ece2346..141565e 100644 --- a/modules/nixos/services/default.nix +++ b/modules/nixos/services/default.nix @@ -15,6 +15,7 @@ ./cloudflare.nix ./filebrowser.nix ./identity.nix + ./immich.nix ./irc.nix ./gitea-runner.nix ./gitea.nix diff --git a/modules/nixos/services/immich.nix b/modules/nixos/services/immich.nix new file mode 100644 index 0000000..cd32bc8 --- /dev/null +++ b/modules/nixos/services/immich.nix @@ -0,0 +1,42 @@ +{ config, lib, ... }: + +{ + + config = lib.mkIf config.services.immich.enable { + + services.immich = { + port = 2283; + group = "shared"; + database.enable = true; + redis.enable = true; + machine-learning.enable = true; + machine-learning.environment = { }; + mediaLocation = "/data/images"; + secretsFile = null; + settings.server.externalDomain = "https://${config.hostnames.photos}"; + environment = { + IMMICH_ENV = "production"; + IMMICH_LOG_LEVEL = "log"; + NO_COLOR = "false"; + IMMICH_TRUSTED_PROXIES = "127.0.0.1"; + }; + }; + + caddy.routes = [ + { + match = [ { host = [ config.hostnames.photos ]; } ]; + handle = [ + { + handler = "reverse_proxy"; + upstreams = [ { dial = "localhost:${builtins.toString config.services.immich.port}"; } ]; + } + ]; + } + ]; + + # Configure Cloudflare DNS to point to this machine + services.cloudflare-dyndns.domains = [ config.hostnames.photos ]; + + }; + +}