From d39f60d75c488244531b30ec740c54168ea18029 Mon Sep 17 00:00:00 2001 From: Fabian Montero Date: Mon, 25 May 2026 01:42:53 -0600 Subject: [PATCH] sys: add immich --- sys/modules/default.nix | 1 + sys/modules/immich.nix | 74 ++++++++++++++++++++++++ sys/platforms/posixlycorrect/default.nix | 5 ++ 3 files changed, 80 insertions(+) create mode 100644 sys/modules/immich.nix diff --git a/sys/modules/default.nix b/sys/modules/default.nix index 3b7cacd..5fb198c 100644 --- a/sys/modules/default.nix +++ b/sys/modules/default.nix @@ -17,6 +17,7 @@ ./steam.nix ./gtklock.nix ./borgsync.nix + ./immich.nix ./dufs.nix ./defaultDesktopPack.nix ./task-force-beta-bot.nix diff --git a/sys/modules/immich.nix b/sys/modules/immich.nix new file mode 100644 index 0000000..cfa7214 --- /dev/null +++ b/sys/modules/immich.nix @@ -0,0 +1,74 @@ +{ + config, + lib, + pkgs, + ... +}: +with lib; let + cfg = config.local.sys.immich; +in { + options.local.sys.immich = { + enable = mkEnableOption "Immich photo/video management"; + mediaLocation = mkOption { + type = types.path; + default = "/var/lib/immich"; + description = "Directory for storing media files."; + }; + host = mkOption { + type = types.str; + default = "127.0.0.1"; + description = "Address to listen on."; + }; + port = mkOption { + type = types.port; + default = 2283; + description = "Port for the web interface."; + }; + machineLearning.enable = mkOption { + type = types.bool; + default = true; + description = "Enable machine learning for smart features."; + }; + accelerationDevices = mkOption { + type = with types; nullOr (listOf str); + default = null; + description = '' + Device paths for hardware-accelerated video transcoding. + null = allow all devices, [] = no acceleration. + Example: [ "/dev/dri/renderD128" ] + ''; + }; + group = mkOption { + type = types.str; + default = "photosgroup"; + description = '' + Group for shared access to external libraries. Files in external + libraries should be owned by this group with group-read permission. + To add permisions to current dir: + `chgrp -R photosgroup . && chmod -R g+rX .` + ''; + }; + users = mkOption { + type = with types; listOf str; + default = []; + description = "Users to add to the photos group for managing external libraries."; + }; + }; + + config = mkIf cfg.enable { + users.groups.${cfg.group} = {}; + users.users = + {immich.extraGroups = [cfg.group];} + // genAttrs cfg.users (_: {extraGroups = [cfg.group];}); + + services.immich = { + enable = true; + host = cfg.host; + port = cfg.port; + mediaLocation = cfg.mediaLocation; + openFirewall = false; + machine-learning.enable = cfg.machineLearning.enable; + accelerationDevices = cfg.accelerationDevices; + }; + }; +} diff --git a/sys/platforms/posixlycorrect/default.nix b/sys/platforms/posixlycorrect/default.nix index 46a03b1..49b8bf1 100644 --- a/sys/platforms/posixlycorrect/default.nix +++ b/sys/platforms/posixlycorrect/default.nix @@ -25,6 +25,11 @@ ]; repoName = "posixlycorrect"; }; + immich = { + enable = true; + accelerationDevices = [ "/dev/dri/renderD128" ]; + users = [ "fabian" ]; + }; }; networking = {