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
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
cfg = config.services.bazarr;
|
2025-01-04 23:17:35 +00:00
|
|
|
cfgInit = config.init.services.bazarr;
|
2025-01-04 10:22:05 +00:00
|
|
|
in {
|
|
|
|
options.services.bazarr = {
|
|
|
|
enable = lib.mkEnableOption "bazarr";
|
|
|
|
package = lib.mkPackageOption pkgs "bazarr" {};
|
2025-01-04 23:17:35 +00:00
|
|
|
|
2025-01-04 10:22:05 +00:00
|
|
|
configDir = lib.mkOption {
|
|
|
|
description = "Where Bazarr's configuration files are stored.";
|
|
|
|
type = lib.types.str;
|
|
|
|
default = "/config";
|
|
|
|
};
|
|
|
|
};
|
2025-01-04 23:17:35 +00:00
|
|
|
|
2025-01-04 10:22:05 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
init.services.bazarr = {
|
|
|
|
enabled = true;
|
2025-01-04 23:17:35 +00:00
|
|
|
user = lib.mkDefault "bazarr";
|
|
|
|
group = lib.mkDefault "bazarr";
|
|
|
|
|
2025-01-04 10:22:05 +00:00
|
|
|
script = pkgs.writeShellScript "bazarr-run" ''
|
2025-01-06 11:58:02 +00:00
|
|
|
umask 0002
|
2025-01-04 10:22:05 +00:00
|
|
|
${lib.getExe cfg.package} \
|
|
|
|
--no-update \
|
|
|
|
--config '${cfg.configDir}'
|
|
|
|
'';
|
|
|
|
};
|
2025-01-04 23:17:35 +00:00
|
|
|
|
2025-01-04 10:22:05 +00:00
|
|
|
environment.systemPackages = [cfg.package];
|
2025-01-04 23:17:35 +00:00
|
|
|
|
2025-01-05 22:08:24 +00:00
|
|
|
users.users.${cfgInit.user} = lib.mkIf (cfgInit.user == "bazarr") (nglib.mkDefaultRec {
|
2025-01-04 23:17:35 +00:00
|
|
|
description = "bazarr";
|
|
|
|
group = cfgInit.group;
|
|
|
|
createHome = false;
|
|
|
|
home = "/var/empty";
|
|
|
|
useDefaultShell = true;
|
|
|
|
uid = config.ids.uids.bazarr;
|
2025-01-05 22:08:24 +00:00
|
|
|
});
|
2025-01-04 23:17:35 +00:00
|
|
|
|
2025-01-05 22:08:24 +00:00
|
|
|
users.groups.${cfgInit.group} = lib.mkIf (cfgInit.group == "bazarr") (nglib.mkDefaultRec {gid = config.ids.gids.bazarr;});
|
2025-01-04 10:22:05 +00:00
|
|
|
};
|
|
|
|
}
|