2025-01-04 10:22:05 +00:00
|
|
|
{
|
|
|
|
lib,
|
2025-01-04 23:17:35 +00:00
|
|
|
nglib,
|
2025-01-04 10:22:05 +00:00
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
cfg = config.services.jellyseerr;
|
2025-01-04 23:17:35 +00:00
|
|
|
cfgInit = config.init.services.jellyseerr;
|
2025-01-04 10:22:05 +00:00
|
|
|
in {
|
|
|
|
options.services.jellyseerr = {
|
|
|
|
enable = lib.mkEnableOption "jellyseerr";
|
|
|
|
package = lib.mkPackageOption pkgs "jellyseerr" {};
|
|
|
|
|
|
|
|
port = lib.mkOption {
|
|
|
|
description = ''
|
|
|
|
The port Jellyseerr should listen on.
|
|
|
|
'';
|
|
|
|
type = lib.types.port;
|
|
|
|
example = 8080;
|
|
|
|
default = 5055;
|
|
|
|
};
|
|
|
|
|
|
|
|
configDir = lib.mkOption {
|
|
|
|
description = ''
|
|
|
|
The directory to save run-time configuration.
|
|
|
|
'';
|
|
|
|
type = lib.types.str;
|
|
|
|
example = "/jellyseerr";
|
|
|
|
default = "/var/lib/jellyseerr";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
init.services.jellyseerr = {
|
|
|
|
enabled = true;
|
2025-01-06 11:58:02 +00:00
|
|
|
script = pkgs.writeShellScript "jellyseerr-run" ''
|
|
|
|
umask 0002
|
|
|
|
${lib.getExe cfg.package}
|
|
|
|
'';
|
2025-01-04 23:17:35 +00:00
|
|
|
user = lib.mkDefault "jellyseerr";
|
|
|
|
group = lib.mkDefault "jellyseerr";
|
2025-01-04 10:22:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
environment = {
|
|
|
|
systemPackages = [cfg.package];
|
2025-01-04 23:17:35 +00:00
|
|
|
|
2025-01-04 10:22:05 +00:00
|
|
|
variables = {
|
|
|
|
PORT = builtins.toString cfg.port;
|
|
|
|
CONFIG_DIRECTORY = cfg.configDir;
|
|
|
|
};
|
|
|
|
};
|
2025-01-04 23:17:35 +00:00
|
|
|
|
2025-01-06 11:58:02 +00:00
|
|
|
users.users.${cfgInit.user} = lib.mkIf (cfgInit.user == "jellyseerr") (nglib.mkDefaultRec {
|
2025-01-04 23:17:35 +00:00
|
|
|
description = "jellyseerr";
|
|
|
|
group = cfgInit.group;
|
|
|
|
createHome = false;
|
|
|
|
home = "/var/empty";
|
|
|
|
useDefaultShell = true;
|
|
|
|
uid = config.ids.uids.jellyseerr;
|
2025-01-06 11:58:02 +00:00
|
|
|
});
|
2025-01-04 23:17:35 +00:00
|
|
|
|
2025-01-06 11:58:02 +00:00
|
|
|
users.groups.${cfgInit.group} = lib.mkIf (cfgInit.group == "jellyseerr") (nglib.mkDefaultRec {gid = config.ids.gids.jellyseerr;});
|
2025-01-04 10:22:05 +00:00
|
|
|
};
|
|
|
|
}
|