mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 17:03:01 +00:00
aa0fc3e8b8
The rss-bridge service changes introduced in f2201789fe
resp. https://github.com/NixOS/nixpkgs/pull/223148 removes the need for
the package patch. This commit removes the patch to ease updating and
maintenance.
Relevant service functionality was also removed (e.g. the setting of
RSSBRIDGE_DATA).
The explicit definition of FileCache.path so users can easily see its
default value and change it, requires to use a freeformType to let users
freely add potentially upcoming config options. This type is restricted
to ini types (although we coerce them to environment variables).
This however makes the list of enabled_bridges impossible. That was
fixed by explicitly introducing this option with a type allowing lists.
The default value however should be unset, which is expressed as `null`,
which further spurred a change in the environment variable generation to
ignore null values (instead of coercing them to an empty string).
A breaking change note was added to highlight this change. A check that
warns users of the not-application of their existing config file is
not easily possible, as people could have only added or changed the
config.ini.php file on the file system without changing a nix variable.
164 lines
4.9 KiB
Nix
164 lines
4.9 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
with lib;
|
|
let
|
|
cfg = config.services.rss-bridge;
|
|
|
|
poolName = "rss-bridge";
|
|
|
|
cfgHalf = lib.mapAttrsRecursive (path: value: let
|
|
envName = lib.toUpper ("RSSBRIDGE_" + lib.concatStringsSep "_" path);
|
|
envValue = if lib.isList value then
|
|
lib.concatStringsSep "," value
|
|
else if lib.isBool value then
|
|
lib.boolToString value
|
|
else
|
|
toString value;
|
|
in if (value != null) then "fastcgi_param \"${envName}\" \"${envValue}\";" else null) cfg.config;
|
|
cfgEnv = lib.concatStringsSep "\n" (lib.collect lib.isString cfgHalf);
|
|
in
|
|
{
|
|
imports = [
|
|
(mkRenamedOptionModule [ "services" "rss-bridge" "whitelist" ] [ "services" "rss-bridge" "config" "system" "enabled_bridges" ])
|
|
];
|
|
|
|
options = {
|
|
services.rss-bridge = {
|
|
enable = mkEnableOption "rss-bridge";
|
|
|
|
user = mkOption {
|
|
type = types.str;
|
|
default = "nginx";
|
|
description = ''
|
|
User account under which both the service and the web-application run.
|
|
'';
|
|
};
|
|
|
|
group = mkOption {
|
|
type = types.str;
|
|
default = "nginx";
|
|
description = ''
|
|
Group under which the web-application run.
|
|
'';
|
|
};
|
|
|
|
pool = mkOption {
|
|
type = types.str;
|
|
default = poolName;
|
|
description = ''
|
|
Name of existing phpfpm pool that is used to run web-application.
|
|
If not specified a pool will be created automatically with
|
|
default values.
|
|
'';
|
|
};
|
|
|
|
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 = ''
|
|
Name of the nginx virtualhost to use and setup. If null, do not setup any virtualhost.
|
|
'';
|
|
};
|
|
|
|
config = mkOption {
|
|
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/";
|
|
defaultText = options.literalExpression "\${config.services.rss-bridge.dataDir}/cache/";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
example = options.literalExpression ''
|
|
{
|
|
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.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
services.phpfpm.pools = mkIf (cfg.pool == poolName) {
|
|
${poolName} = {
|
|
user = cfg.user;
|
|
settings = mapAttrs (name: mkDefault) {
|
|
"listen.owner" = cfg.user;
|
|
"listen.group" = cfg.user;
|
|
"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;
|
|
};
|
|
};
|
|
};
|
|
|
|
systemd.tmpfiles.settings.rss-bridge = {
|
|
"${cfg.config.FileCache.path}".d = {
|
|
mode = "0750";
|
|
user = cfg.user;
|
|
group = cfg.group;
|
|
};
|
|
};
|
|
|
|
services.nginx = mkIf (cfg.virtualHost != null) {
|
|
enable = true;
|
|
virtualHosts = {
|
|
${cfg.virtualHost} = {
|
|
root = "${pkgs.rss-bridge}";
|
|
|
|
locations."/" = {
|
|
tryFiles = "$uri /index.php$is_args$args";
|
|
};
|
|
|
|
locations."~ ^/index.php(/|$)" = {
|
|
extraConfig = ''
|
|
include ${config.services.nginx.package}/conf/fastcgi_params;
|
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
|
fastcgi_pass unix:${config.services.phpfpm.pools.${cfg.pool}.socket};
|
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
${cfgEnv}
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|