86 lines
1.8 KiB
Nix
86 lines
1.8 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.my.services.immich;
|
|
in
|
|
{
|
|
|
|
options.my.services.immich = {
|
|
enable = lib.mkEnableOption "Enable Immich photo albums module";
|
|
|
|
mediaDir = lib.mkOption {
|
|
type = lib.types.path;
|
|
default = "/var/lib/immich/media";
|
|
description = "Directory with Immich will store media files";
|
|
};
|
|
|
|
settings = lib.mkOption {
|
|
type = lib.types.attrsOf lib.types.any;
|
|
default = { };
|
|
description = ''
|
|
Settings for Immich
|
|
'';
|
|
};
|
|
|
|
proxy = {
|
|
enable = lib.mkEnableOption "Set the proxy entry for this service";
|
|
|
|
domain = lib.mkOption {
|
|
default = "example.com";
|
|
type = lib.types.str;
|
|
description = ''
|
|
The domain where Caddy is reachable
|
|
'';
|
|
};
|
|
|
|
subdomain = lib.mkOption {
|
|
default = "photos";
|
|
type = lib.types.str;
|
|
description = ''
|
|
The subdomain where Immich is reachable
|
|
'';
|
|
};
|
|
|
|
host = lib.mkOption {
|
|
default = "localhost";
|
|
type = lib.types.str;
|
|
description = ''
|
|
host name where the service is running
|
|
'';
|
|
};
|
|
|
|
};
|
|
};
|
|
|
|
config = lib.mkMerge [
|
|
(lib.mkIf cfg.enable {
|
|
|
|
services.immich = {
|
|
enable = true;
|
|
host = "0.0.0.0";
|
|
openFirewall = true;
|
|
redis.enable = true;
|
|
mediaLocation = cfg.mediaDir;
|
|
machine-learning.enable = true;
|
|
database = {
|
|
enable = true;
|
|
createDB = true;
|
|
};
|
|
};
|
|
|
|
})
|
|
|
|
(lib.mkIf cfg.proxy.enable {
|
|
services.caddy = with cfg.proxy; {
|
|
virtualHosts."${subdomain}.${domain}".extraConfig = ''
|
|
reverse_proxy http://${host}:${toString config.services.immich.port}
|
|
import cloudflare_${domain}
|
|
'';
|
|
};
|
|
})
|
|
];
|
|
}
|