From dc32165b5c06866bf29a4930dbd005bc96fb37c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Fri, 27 Sep 2024 20:04:41 +0300 Subject: [PATCH] immich: +bindPaths wip --- hosts/fwminex/configuration.nix | 3 ++- modules/services/immich/default.nix | 24 +++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/hosts/fwminex/configuration.nix b/hosts/fwminex/configuration.nix index 0a2a34b..d52b719 100644 --- a/hosts/fwminex/configuration.nix +++ b/hosts/fwminex/configuration.nix @@ -443,7 +443,8 @@ in immich = { enable = true; - paths = { + bindAsUser = "motiejus"; + bindPaths = { "M-Camera" = "/home/motiejus/annex2/M-Active"; "Pictures" = "/home/motiejus/annex2/Pictures"; }; diff --git a/modules/services/immich/default.nix b/modules/services/immich/default.nix index 675da37..985536f 100644 --- a/modules/services/immich/default.nix +++ b/modules/services/immich/default.nix @@ -12,7 +12,8 @@ in { options.mj.services.immich = with lib.types; { enable = lib.mkEnableOption "enable immich"; - paths = lib.mkOption { type = attrsOf str; }; + bindPaths = lib.mkOption { type = attrsOf str; }; + bindAsUser = lib.mkOption { type = str; }; }; imports = [ "${nixpkgs-unstable}/nixos/modules/services/web-apps/immich.nix" ]; @@ -29,16 +30,17 @@ in reverse_proxy localhost:${toString myData.ports.immich-server} ''; - #systemd = { - # #tmpfiles.rules = [ "d /var/cache/immich/userdata 0700 immich immich -" ]; - # services.immich-server.serviceConfig = { - # #ProtectHome = lib.mkForce "tmpfs"; - # #CacheDirectory = "immich"; - # #BindPaths = lib.mapAttrsToList ( - # # name: srcpath: "${srcpath}:/var/cache/immich/userdata/${name}" - # #) cfg.paths; - # }; - #}; + 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; + }; + }; };