2024-09-27 15:03:43 +03:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
myData,
|
|
|
|
nixpkgs-unstable,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
cfg = config.mj.services.immich;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.mj.services.immich = with lib.types; {
|
|
|
|
enable = lib.mkEnableOption "enable immich";
|
2024-09-27 20:04:41 +03:00
|
|
|
bindPaths = lib.mkOption { type = attrsOf str; };
|
|
|
|
bindAsUser = lib.mkOption { type = str; };
|
2024-09-27 15:03:43 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
imports = [ "${nixpkgs-unstable}/nixos/modules/services/web-apps/immich.nix" ];
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.immich = {
|
|
|
|
enable = true;
|
2024-09-27 15:11:54 +03:00
|
|
|
port = myData.ports.immich-server;
|
2024-09-27 15:03:43 +03:00
|
|
|
package = pkgs.pkgs-unstable.immich;
|
|
|
|
};
|
|
|
|
|
2024-09-27 15:56:20 +03:00
|
|
|
services.caddy.virtualHosts."photos2.jakstys.lt:80".extraConfig = ''
|
2024-09-27 15:46:44 +03:00
|
|
|
@denied not remote_ip ${myData.subnets.tailscale.cidr}
|
2024-09-27 16:01:47 +03:00
|
|
|
reverse_proxy localhost:${toString myData.ports.immich-server}
|
2024-09-27 15:46:44 +03:00
|
|
|
'';
|
2024-09-27 15:03:43 +03:00
|
|
|
|
2024-09-27 20:04:41 +03:00
|
|
|
systemd = {
|
|
|
|
tmpfiles.rules = [
|
|
|
|
"d /var/cache/immich/userdata 0700 immich immich -"
|
|
|
|
] ++ lib.mapAttrsToList (name: _: "/var/cache/immich/userdata/${name}") cfg.bindPaths;
|
|
|
|
services.immich-server.serviceConfig = {
|
|
|
|
ExecStartPre = lib.mapAttrsToList (
|
|
|
|
name: srcpath:
|
|
|
|
"+${pkgs.bindfs}/bin/bindfs -u ${cfg.bindAsUser} ${srcpath} /var/cache/immich/userdata/${name}"
|
|
|
|
) cfg.bindPaths;
|
|
|
|
};
|
|
|
|
};
|
2024-09-27 15:03:43 +03:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|