immich.nix 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. { config, ... }:
  2. let
  3. cfg = config.services.immich;
  4. domain = "photos.t5.st";
  5. in
  6. {
  7. services.immich = {
  8. enable = true;
  9. host = "127.0.0.1";
  10. mediaLocation = "/mnt/storage/immich";
  11. group = "storage";
  12. accelerationDevices = [ "/dev/dri/renderD128" ];
  13. # environment = {
  14. # INFO: Not needed but left for reference
  15. # ENCODED_VIDEO_LOCATION = "/var/cache/immich/encoded-video";
  16. # MPLCONFIGDIR = "/var/cache/immich/mpl";
  17. # PROFILE_LOCATION = "/var/cache/immich/profile";
  18. # THUMB_LOCATION = "/var/cache/immich/thumbs";
  19. # };
  20. settings = {
  21. metadata.faces.import = true;
  22. newVersionCheck.enabled = false;
  23. server.externalDomain = "https://${domain}";
  24. storageTemplate = {
  25. enabled = true;
  26. hashVerificationEnabled = true;
  27. template = "{{y}}/{{MM}}/{{dd}}/{{filename}}";
  28. };
  29. # TODO: add smtp authentication to environment
  30. # notifications.smtp.enabled = true;
  31. # notifications.smtp.from = "Odin Photos <[email protected]>";
  32. };
  33. };
  34. services.cloudflared.tunnels."71c89a7f-2467-444c-9fda-4864860dc8c4" = {
  35. credentialsFile =
  36. config.age.secrets."odin/services/cloudflared-tunnel".path;
  37. default = "http_status:404";
  38. ingress."${domain}".service =
  39. "http://${cfg.host}:${toString cfg.port}";
  40. };
  41. services.caddy.virtualHosts.immich = {
  42. hostName = "photos.{$DOMAIN}";
  43. extraConfig = ''
  44. encode gzip zstd
  45. reverse_proxy ${cfg.host}:${toString cfg.port}
  46. '';
  47. };
  48. systemd.tmpfiles.rules = [
  49. "d /mnt/storage/immich 0770 immich storage - -"
  50. "d /var/cache/immich/mpl 0700 immich storage - -"
  51. "d /var/cache/immich/encoded-video 0700 immich storage - -"
  52. "d /var/cache/immich/profile 0700 immich storage - -"
  53. "d /var/cache/immich/thumbs 0700 immich storage - -"
  54. ];
  55. system.activationScripts.createSymlink = ''
  56. ln -sf /mnt/storage/immich/encoded-video /var/cache/immich/encoded-video
  57. ln -sf /mnt/storage/immich/profile /var/cache/immich/profile
  58. ln -sf /mnt/storage/immich/thumbs /var/cache/immich/thumbs
  59. '';
  60. services.samba.settings = {
  61. christine-photos = {
  62. "path" = "/mnt/storage/immich/library/3aaaf0a1-011e-450d-a47c-4a320deb93e5";
  63. "browseable" = "yes";
  64. "read only" = "yes";
  65. "valid users" = "christine";
  66. "force user" = "immich";
  67. };
  68. };
  69. }