|
- {
- description = "NixOS Immich server";
-
- inputs = {
- nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
- };
-
- outputs = { self, nixpkgs, ... }: {
-
- nixosModules.immich = { config, lib, pkgs, ... }:
- let
- cfg = config.immich;
- in
- {
- options.immich = {
- enable = lib.mkOption {type = lib.types.bool;};
- port = lib.mkOption {type = lib.types.ints.unsigned;};
- };
-
- config = lib.mkIf cfg.enable {
- # https://medium.com/@piyushkumarsingh.nmims/self-hosting-your-photos-with-immich-on-nixos-its-easier-than-you-think-c3d14fcabad1
- services.immich = {
- enable = true;
- port = cfg.port;
- host = "0.0.0.0"; # Makes it accessible on your network
- mediaLocation = "/var/lib/immich"; # Ensure this has enough space
- openFirewall = true; # Auto-opens the port
- };
-
- # nginx virtual host
- services.nginx.virtualHosts.${cfg.hostName} = {
- enableACME = true;
- acmeRoot = null;
- addSSL = true;
- # directs traffic to the appropriate port
- locations."/" = {
- proxyPass = "http://localhost:${cfg.port}";
- proxyWebsockets = true;
- };
- };
- };
- };
- };
- }
|