Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

45 lines
1.3KB

  1. {
  2. description = "NixOS Immich server";
  3. inputs = {
  4. nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
  5. };
  6. outputs = { self, nixpkgs, ... }: {
  7. nixosModules.immich = { config, lib, pkgs, ... }:
  8. let
  9. cfg = config.immich;
  10. in
  11. {
  12. options.immich = {
  13. enable = lib.mkOption {type = lib.types.bool;};
  14. port = lib.mkOption {type = lib.types.ints.unsigned;};
  15. };
  16. config = lib.mkIf cfg.enable {
  17. # https://medium.com/@piyushkumarsingh.nmims/self-hosting-your-photos-with-immich-on-nixos-its-easier-than-you-think-c3d14fcabad1
  18. services.immich = {
  19. enable = true;
  20. port = cfg.port;
  21. host = "0.0.0.0"; # Makes it accessible on your network
  22. mediaLocation = "/var/lib/immich"; # Ensure this has enough space
  23. openFirewall = true; # Auto-opens the port
  24. };
  25. # nginx virtual host
  26. services.nginx.virtualHosts.${cfg.hostName} = {
  27. enableACME = true;
  28. acmeRoot = null;
  29. addSSL = true;
  30. # directs traffic to the appropriate port
  31. locations."/" = {
  32. proxyPass = "http://localhost:${cfg.port}";
  33. proxyWebsockets = true;
  34. };
  35. };
  36. };
  37. };
  38. };
  39. }