mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-20 04:19:00 +02:00
Merge pull request #223148 from Mynacol/rss-bridge-config
rss-bridge: add config option
This commit is contained in:
commit
8042af035c
|
@ -5,10 +5,23 @@ let
|
||||||
|
|
||||||
poolName = "rss-bridge";
|
poolName = "rss-bridge";
|
||||||
|
|
||||||
whitelist = pkgs.writeText "rss-bridge_whitelist.txt"
|
configAttr = lib.recursiveUpdate { FileCache.path = "${cfg.dataDir}/cache/"; } cfg.config;
|
||||||
(concatStringsSep "\n" cfg.whitelist);
|
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 "fastcgi_param \"${envName}\" \"${envValue}\";") configAttr;
|
||||||
|
cfgEnv = lib.concatStringsSep "\n" (lib.collect lib.isString cfgHalf);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
imports = [
|
||||||
|
(mkRenamedOptionModule [ "services" "rss-bridge" "whitelist" ] [ "services" "rss-bridge" "config" "system" "enabled_bridges" ])
|
||||||
|
];
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
services.rss-bridge = {
|
services.rss-bridge = {
|
||||||
enable = mkEnableOption (lib.mdDoc "rss-bridge");
|
enable = mkEnableOption (lib.mdDoc "rss-bridge");
|
||||||
|
@ -56,20 +69,26 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
whitelist = mkOption {
|
config = mkOption {
|
||||||
type = types.listOf types.str;
|
type = with types; attrsOf (attrsOf (oneOf [ bool int str (listOf str) ]));
|
||||||
default = [];
|
default = {};
|
||||||
|
defaultText = options.literalExpression "FileCache.path = \"\${config.services.rss-bridge.dataDir}/cache/\"";
|
||||||
example = options.literalExpression ''
|
example = options.literalExpression ''
|
||||||
[
|
{
|
||||||
"Facebook"
|
system.enabled_bridges = [ "*" ];
|
||||||
"Instagram"
|
error = {
|
||||||
"Twitter"
|
output = "http";
|
||||||
]
|
report_limit = 5;
|
||||||
|
};
|
||||||
|
FileCache = {
|
||||||
|
enable_purge = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
'';
|
'';
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
List of bridges to be whitelisted.
|
Attribute set of arbitrary config options.
|
||||||
If the list is empty, rss-bridge will use whitelist.default.txt.
|
Please consult the documentation at the [wiki](https://rss-bridge.github.io/rss-bridge/For_Hosts/Custom_Configuration.html)
|
||||||
Use `[ "*" ]` to whitelist all.
|
and [sample config](https://github.com/RSS-Bridge/rss-bridge/blob/master/config.default.ini.php) to see a list of available options.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -93,11 +112,16 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.settings.rss-bridge = let
|
||||||
"d '${cfg.dataDir}/cache' 0750 ${cfg.user} ${cfg.group} - -"
|
perm = {
|
||||||
(mkIf (cfg.whitelist != []) "L+ ${cfg.dataDir}/whitelist.txt - - - - ${whitelist}")
|
mode = "0750";
|
||||||
"z '${cfg.dataDir}/config.ini.php' 0750 ${cfg.user} ${cfg.group} - -"
|
user = cfg.user;
|
||||||
];
|
group = cfg.group;
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
"${configAttr.FileCache.path}".d = perm;
|
||||||
|
"${cfg.dataDir}/config.ini.php".z = perm;
|
||||||
|
};
|
||||||
|
|
||||||
services.nginx = mkIf (cfg.virtualHost != null) {
|
services.nginx = mkIf (cfg.virtualHost != null) {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -116,6 +140,7 @@ in
|
||||||
fastcgi_pass unix:${config.services.phpfpm.pools.${cfg.pool}.socket};
|
fastcgi_pass unix:${config.services.phpfpm.pools.${cfg.pool}.socket};
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
fastcgi_param RSSBRIDGE_DATA ${cfg.dataDir};
|
fastcgi_param RSSBRIDGE_DATA ${cfg.dataDir};
|
||||||
|
${cfgEnv}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue