From d40f0649255dd29bac858cad1997a2e9576e6111 Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Sat, 26 Apr 2025 14:51:16 +0100 Subject: [PATCH] feat: switch immich to modules/ --- hosts/architect/default.nix | 18 ++++++------ hosts/architect/gitea.nix | 34 ----------------------- hosts/architect/immich.nix | 35 ----------------------- modules/services/default.nix | 5 +++- modules/services/immich/default.nix | 43 +++++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 78 deletions(-) delete mode 100644 hosts/architect/gitea.nix delete mode 100644 hosts/architect/immich.nix create mode 100644 modules/services/immich/default.nix diff --git a/hosts/architect/default.nix b/hosts/architect/default.nix index 05c9d26..26b4bcc 100644 --- a/hosts/architect/default.nix +++ b/hosts/architect/default.nix @@ -24,17 +24,12 @@ in ./matrix.nix ./fail2ban.nix ./dns.nix - # ./minecraft.nix ./prowlarr.nix ./redlib.nix - # ./invidious.nix ./jellyfin.nix - # ./docker.nix ./tailscale.nix ./headscale.nix ./llm.nix - # ./photoprism.nix - ./immich.nix ./sunshine.nix ./jellyseer.nix ./postgres.nix @@ -156,9 +151,16 @@ in smartd.enable = true; }; - pepe.services.gitea = { - enable = true; - domain = "git.giugl.io"; + pepe.services = { + gitea = { + enable = true; + domain = "git.giugl.io"; + }; + immich = { + enable = true; + domain = "photos.giugl.io"; + package = pkgs.unstablePkgs.immich; + }; }; } diff --git a/hosts/architect/gitea.nix b/hosts/architect/gitea.nix deleted file mode 100644 index 3688c38..0000000 --- a/hosts/architect/gitea.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ config, lib, ... }: - -let - domain = "git.giugl.io"; -in -{ - architect = { - firewall.openTCP = [ config.services.gitea.settings.server.SSH_PORT ]; - vhost.${domain} = { - dnsInterfaces = [ "lan" "tailscale" ]; - locations."/" = { - port = config.services.gitea.settings.server.HTTP_PORT; - allowWAN = true; - }; - }; - }; - - services.gitea = { - enable = true; - database.type = "sqlite3"; - appName = "Gitea"; - # https://github.com/NixOS/nixpkgs/issues/235442#issuecomment-1574329453 - lfs.enable = true; - settings = { - server = { - DOMAIN = domain; - ROOT_URL = "https://${domain}"; - SSH_PORT = 22; - HTTP_PORT = 3001; - }; - openid.enable_openid_signin = true; - }; - }; -} diff --git a/hosts/architect/immich.nix b/hosts/architect/immich.nix deleted file mode 100644 index bb530e1..0000000 --- a/hosts/architect/immich.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ config, pkgs, lib, ... }: - -let - domain = "photos.giugl.io"; -in -{ - # disabledModules = [ "services/web-apps/immich.nix" ]; - services = { - immich = { - enable = true; - package = pkgs.unstablePkgs.immich; - # accelerationDevices = null; - # settings.server.externalDomain = "https://${domain}"; - }; - }; - - architect.vhost.${domain} = { - dnsInterfaces = [ "tailscale" "lan" ]; - locations."/" = { - host = "[::1]"; - port = config.services.immich.port; - allowLan = true; - allowWAN = true; - allow = [ config.architect.networks."tailscale".net ]; - proxyWebsockets = true; - extraConfig = '' - # allow large file uploads - client_max_body_size 50000M; - ''; - }; - }; - - - users.users.immich.extraGroups = [ "video" "render" "media" "nextcloud" ]; -} diff --git a/modules/services/default.nix b/modules/services/default.nix index f9640c7..058ee9c 100644 --- a/modules/services/default.nix +++ b/modules/services/default.nix @@ -1,3 +1,6 @@ { ... }: { - imports = [ ./gitea]; + imports = [ + ./gitea + ./immich + ]; } diff --git a/modules/services/immich/default.nix b/modules/services/immich/default.nix new file mode 100644 index 0000000..a67da22 --- /dev/null +++ b/modules/services/immich/default.nix @@ -0,0 +1,43 @@ +{ config, pkgs, lib, ... }: + +let + cfg = config.pepe.services.immich; +in +{ + options.pepe.services.immich = with lib; { + enable = mkEnableOption "Enable immich"; + package = mkPackageOption pkgs "immich" { }; + domain = mkOption { + type = types.str; + default = null; + }; + }; + + config = lib.mkIf cfg.enable { + services = { + immich = { + enable = true; + package = cfg.package; + # accelerationDevices = null; + }; + }; + + architect.vhost.${cfg.domain} = { + dnsInterfaces = [ "tailscale" "lan" ]; + locations."/" = { + host = "[::1]"; + port = config.services.immich.port; + allowLan = true; + allowWAN = true; + allow = [ config.architect.networks."tailscale".net ]; + proxyWebsockets = true; + extraConfig = '' + # allow large file uploads + client_max_body_size 50000M; + ''; + }; + }; + + users.users.immich.extraGroups = [ "video" "render" "media" "nextcloud" ]; + }; +}