2020-08-13 19:51:03 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
2024-11-16 18:03:12 +01:00
|
|
|
inherit (lib)
|
|
|
|
literalExpression
|
|
|
|
mkDefault
|
|
|
|
mkEnableOption
|
|
|
|
mkIf
|
|
|
|
mkOption
|
2025-02-10 23:28:03 +01:00
|
|
|
mkPackageOption
|
2024-11-16 18:03:12 +01:00
|
|
|
mkRenamedOptionModule
|
|
|
|
types
|
|
|
|
;
|
|
|
|
|
2020-08-13 19:51:03 +02:00
|
|
|
cfg = config.services.rss-bridge;
|
|
|
|
|
2024-11-16 18:03:12 +01:00
|
|
|
cfgEnv = lib.pipe cfg.config [
|
|
|
|
(lib.mapAttrsRecursive (
|
|
|
|
path: value:
|
|
|
|
lib.optionalAttrs (value != null) {
|
|
|
|
name = lib.toUpper "RSSBRIDGE_${lib.concatStringsSep "_" path}";
|
|
|
|
value =
|
|
|
|
if lib.isList value then
|
|
|
|
lib.concatStringsSep "," value
|
|
|
|
else if lib.isBool value then
|
|
|
|
lib.boolToString value
|
|
|
|
else
|
|
|
|
toString value;
|
|
|
|
}
|
|
|
|
))
|
|
|
|
(lib.collect (x: lib.isString x.name or false && lib.isString x.value or false))
|
|
|
|
lib.listToAttrs
|
|
|
|
];
|
2020-08-13 19:51:03 +02:00
|
|
|
in
|
|
|
|
{
|
2023-12-30 00:34:49 +01:00
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule
|
2024-11-16 18:03:12 +01:00
|
|
|
[
|
|
|
|
"services"
|
|
|
|
"rss-bridge"
|
|
|
|
"whitelist"
|
|
|
|
]
|
|
|
|
[
|
|
|
|
"services"
|
|
|
|
"rss-bridge"
|
|
|
|
"config"
|
|
|
|
"system"
|
|
|
|
"enabled_bridges"
|
|
|
|
]
|
2023-12-30 00:34:49 +01:00
|
|
|
)
|
|
|
|
];
|
|
|
|
|
2020-08-13 19:51:03 +02:00
|
|
|
options = {
|
|
|
|
services.rss-bridge = {
|
|
|
|
enable = mkEnableOption "rss-bridge";
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
2025-02-10 23:30:07 +01:00
|
|
|
default = if cfg.webserver == null then "rss-bridge" else cfg.webserver;
|
|
|
|
defaultText = "{option}`config.services.rss-bridge.webserver` or \"rss-bridge\"";
|
2020-08-13 19:51:03 +02:00
|
|
|
description = ''
|
2025-02-10 23:30:07 +01:00
|
|
|
The user account under which both the service and the web application run.
|
2020-08-13 19:51:03 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
2025-02-10 23:30:07 +01:00
|
|
|
default = if cfg.webserver == null then "rss-bridge" else cfg.webserver;
|
|
|
|
defaultText = "{option}`config.services.rss-bridge.webserver` or \"rss-bridge\"";
|
2020-08-13 19:51:03 +02:00
|
|
|
description = ''
|
2025-02-10 23:30:07 +01:00
|
|
|
The group under which the web application runs.
|
2020-08-13 19:51:03 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2025-02-10 23:28:03 +01:00
|
|
|
package = mkPackageOption pkgs "rss-bridge" { };
|
|
|
|
|
2020-08-13 19:51:03 +02:00
|
|
|
pool = mkOption {
|
2024-11-16 18:03:12 +01:00
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = "rss-bridge";
|
2020-08-13 19:51:03 +02:00
|
|
|
description = ''
|
2024-11-16 18:03:12 +01:00
|
|
|
Name of phpfpm pool that is used to run web-application.
|
|
|
|
If `null` specified none will be created, otherwise automatically created with default values.
|
2020-08-13 19:51:03 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/rss-bridge";
|
|
|
|
description = ''
|
|
|
|
Location in which cache directory will be created.
|
|
|
|
You can put `config.ini.php` in here.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
virtualHost = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = "rss-bridge";
|
|
|
|
description = ''
|
2025-02-10 23:30:07 +01:00
|
|
|
Name of the nginx or caddy virtualhost to use and setup. If null, do not setup any virtualhost.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
webserver = mkOption {
|
|
|
|
type = types.nullOr (
|
|
|
|
types.enum [
|
|
|
|
"nginx"
|
|
|
|
"caddy"
|
|
|
|
]
|
|
|
|
);
|
|
|
|
default = "nginx";
|
|
|
|
description = ''
|
|
|
|
Type of virtualhost to use and setup. If null, do not setup any virtualhost.
|
2020-08-13 19:51:03 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-12-30 00:09:48 +01:00
|
|
|
config = mkOption {
|
2024-07-31 14:38:43 +02:00
|
|
|
type = types.submodule {
|
|
|
|
freeformType = (pkgs.formats.ini { }).type;
|
|
|
|
options = {
|
|
|
|
system = {
|
|
|
|
enabled_bridges = mkOption {
|
|
|
|
type = with types; nullOr (either str (listOf str));
|
|
|
|
description = "Only enabled bridges are available for feed production";
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
FileCache = {
|
|
|
|
path = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Directory where to store cache files (if cache.type = \"file\").";
|
|
|
|
default = "${cfg.dataDir}/cache/";
|
2024-11-16 18:03:12 +01:00
|
|
|
defaultText = literalExpression "\${config.services.rss-bridge.dataDir}/cache/";
|
2024-07-31 14:38:43 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-11-16 18:03:12 +01:00
|
|
|
example = literalExpression ''
|
2023-12-30 00:09:48 +01:00
|
|
|
{
|
|
|
|
system.enabled_bridges = [ "*" ];
|
|
|
|
error = {
|
|
|
|
output = "http";
|
|
|
|
report_limit = 5;
|
|
|
|
};
|
|
|
|
FileCache = {
|
|
|
|
enable_purge = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Attribute set of arbitrary config options.
|
|
|
|
Please consult the documentation at the [wiki](https://rss-bridge.github.io/rss-bridge/For_Hosts/Custom_Configuration.html)
|
|
|
|
and [sample config](https://github.com/RSS-Bridge/rss-bridge/blob/master/config.default.ini.php) to see a list of available options.
|
|
|
|
'';
|
|
|
|
};
|
2020-08-13 19:51:03 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2024-11-16 18:03:12 +01:00
|
|
|
services.phpfpm.pools = mkIf (cfg.pool != null) {
|
|
|
|
${cfg.pool} = {
|
2020-08-13 19:51:03 +02:00
|
|
|
user = cfg.user;
|
2024-11-16 18:03:12 +01:00
|
|
|
settings = lib.mapAttrs (name: mkDefault) {
|
2020-08-13 19:51:03 +02:00
|
|
|
"listen.owner" = cfg.user;
|
2024-11-16 18:03:12 +01:00
|
|
|
"listen.group" = cfg.group;
|
2020-08-13 19:51:03 +02:00
|
|
|
"listen.mode" = "0600";
|
|
|
|
"pm" = "dynamic";
|
|
|
|
"pm.max_children" = 75;
|
|
|
|
"pm.start_servers" = 10;
|
|
|
|
"pm.min_spare_servers" = 5;
|
|
|
|
"pm.max_spare_servers" = 20;
|
|
|
|
"pm.max_requests" = 500;
|
|
|
|
"catch_workers_output" = 1;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-07-31 14:38:43 +02:00
|
|
|
|
|
|
|
systemd.tmpfiles.settings.rss-bridge = {
|
|
|
|
"${cfg.config.FileCache.path}".d = {
|
|
|
|
mode = "0750";
|
|
|
|
user = cfg.user;
|
|
|
|
group = cfg.group;
|
|
|
|
};
|
2024-02-14 18:44:37 +01:00
|
|
|
};
|
2020-08-13 19:51:03 +02:00
|
|
|
|
2025-02-10 23:30:07 +01:00
|
|
|
services.nginx = mkIf (cfg.virtualHost != null && cfg.webserver == "nginx") {
|
2020-08-13 19:51:03 +02:00
|
|
|
enable = true;
|
|
|
|
virtualHosts = {
|
|
|
|
${cfg.virtualHost} = {
|
2025-02-10 23:28:03 +01:00
|
|
|
root = "${cfg.package}";
|
2020-08-13 19:51:03 +02:00
|
|
|
|
|
|
|
locations."/" = {
|
|
|
|
tryFiles = "$uri /index.php$is_args$args";
|
|
|
|
};
|
|
|
|
|
2023-12-30 01:15:50 +01:00
|
|
|
locations."~ ^/index.php(/|$)" = {
|
2020-08-13 19:51:03 +02:00
|
|
|
extraConfig = ''
|
2022-02-08 12:13:30 +01:00
|
|
|
include ${config.services.nginx.package}/conf/fastcgi_params;
|
2020-08-13 19:51:03 +02:00
|
|
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
|
|
|
fastcgi_pass unix:${config.services.phpfpm.pools.${cfg.pool}.socket};
|
|
|
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
2024-11-16 18:03:12 +01:00
|
|
|
${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "fastcgi_param \"${n}\" \"${v}\";") cfgEnv)}
|
2020-08-13 19:51:03 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2025-02-10 23:30:07 +01:00
|
|
|
|
|
|
|
services.caddy = mkIf (cfg.virtualHost != null && cfg.webserver == "caddy") {
|
|
|
|
enable = true;
|
|
|
|
virtualHosts.${cfg.virtualHost} = {
|
|
|
|
extraConfig = ''
|
|
|
|
root * ${cfg.package}
|
|
|
|
file_server
|
|
|
|
php_fastcgi unix/${config.services.phpfpm.pools.${cfg.pool}.socket} {
|
|
|
|
${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: " env ${n} \"${v}\"") cfgEnv)}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2020-08-13 19:51:03 +02:00
|
|
|
};
|
2024-11-16 18:07:31 +01:00
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ quantenzitrone ];
|
2020-08-13 19:51:03 +02:00
|
|
|
}
|