rss-bridge: Remove pkg patch, adapt nixos service
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.
This commit is contained in:
parent
ed96506b5d
commit
aa0fc3e8b8
@ -442,6 +442,9 @@
|
||||
- `ffmpeg_5` has been removed. Please use the unversioned `ffmpeg`,
|
||||
pin a newer version, or if necessary pin `ffmpeg_4` for compatibility.
|
||||
|
||||
- The `rss-bridge` service drops the support to load a configuration file from `${config.services.rss-bridge.dataDir}/config.ini.php`.
|
||||
Consider using the `services.rss-bridge.config` option instead.
|
||||
|
||||
- The `xdg.portal.gtkUsePortal` option has been removed, as it had been deprecated for over 2 years. Using the `GTK_USE_PORTAL` environment variable in this manner is not intended nor encouraged by the GTK developers, but can still be done manually via `environment.sessionVariables`.
|
||||
|
||||
- The `services.trust-dns` module has been renamed to `services.hickory-dns`.
|
||||
|
@ -5,7 +5,6 @@ let
|
||||
|
||||
poolName = "rss-bridge";
|
||||
|
||||
configAttr = lib.recursiveUpdate { FileCache.path = "${cfg.dataDir}/cache/"; } cfg.config;
|
||||
cfgHalf = lib.mapAttrsRecursive (path: value: let
|
||||
envName = lib.toUpper ("RSSBRIDGE_" + lib.concatStringsSep "_" path);
|
||||
envValue = if lib.isList value then
|
||||
@ -14,7 +13,7 @@ let
|
||||
lib.boolToString value
|
||||
else
|
||||
toString value;
|
||||
in "fastcgi_param \"${envName}\" \"${envValue}\";") configAttr;
|
||||
in if (value != null) then "fastcgi_param \"${envName}\" \"${envValue}\";" else null) cfg.config;
|
||||
cfgEnv = lib.concatStringsSep "\n" (lib.collect lib.isString cfgHalf);
|
||||
in
|
||||
{
|
||||
@ -70,9 +69,26 @@ in
|
||||
};
|
||||
|
||||
config = mkOption {
|
||||
type = with types; attrsOf (attrsOf (oneOf [ bool int str (listOf str) ]));
|
||||
default = {};
|
||||
defaultText = options.literalExpression "FileCache.path = \"\${config.services.rss-bridge.dataDir}/cache/\"";
|
||||
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 = [ "*" ];
|
||||
@ -112,15 +128,13 @@ in
|
||||
};
|
||||
};
|
||||
};
|
||||
systemd.tmpfiles.settings.rss-bridge = let
|
||||
perm = {
|
||||
mode = "0750";
|
||||
user = cfg.user;
|
||||
group = cfg.group;
|
||||
};
|
||||
in {
|
||||
"${configAttr.FileCache.path}".d = perm;
|
||||
"${cfg.dataDir}/config.ini.php".z = perm;
|
||||
|
||||
systemd.tmpfiles.settings.rss-bridge = {
|
||||
"${cfg.config.FileCache.path}".d = {
|
||||
mode = "0750";
|
||||
user = cfg.user;
|
||||
group = cfg.group;
|
||||
};
|
||||
};
|
||||
|
||||
services.nginx = mkIf (cfg.virtualHost != null) {
|
||||
@ -139,7 +153,6 @@ in
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass unix:${config.services.phpfpm.pools.${cfg.pool}.socket};
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param RSSBRIDGE_DATA ${cfg.dataDir};
|
||||
${cfgEnv}
|
||||
'';
|
||||
};
|
||||
|
@ -11,10 +11,6 @@ stdenv.mkDerivation rec {
|
||||
sha256 = "sha256-VycEgu7uHYwDnNE1eoVxgaWZAnC6mZLBxT8Le3PI4Rs=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
./paths.patch
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir $out/
|
||||
cp -R ./* $out
|
||||
|
@ -1,38 +0,0 @@
|
||||
diff --git a/lib/Configuration.php b/lib/Configuration.php
|
||||
index 63f67a3c..f0a53a24 100644
|
||||
--- a/lib/Configuration.php
|
||||
+++ b/lib/Configuration.php
|
||||
@@ -81,8 +81,8 @@ public static function loadConfiguration(array $customConfig = [], array $env =
|
||||
}
|
||||
}
|
||||
|
||||
- if (file_exists(__DIR__ . '/../whitelist.txt')) {
|
||||
- $enabledBridges = trim(file_get_contents(__DIR__ . '/../whitelist.txt'));
|
||||
+ if (file_exists(getenv('RSSBRIDGE_DATA') . '/whitelist.txt')) {
|
||||
+ $enabledBridges = trim(file_get_contents(getenv('RSSBRIDGE_DATA') . '/whitelist.txt'));
|
||||
if ($enabledBridges === '*') {
|
||||
self::setConfig('system', 'enabled_bridges', ['*']);
|
||||
} else {
|
||||
diff --git a/lib/bootstrap.php b/lib/bootstrap.php
|
||||
index 6465f5f9..4605596f 100644
|
||||
--- a/lib/bootstrap.php
|
||||
+++ b/lib/bootstrap.php
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
const PATH_LIB_CACHES = __DIR__ . '/../caches/';
|
||||
-const PATH_CACHE = __DIR__ . '/../cache/';
|
||||
+define('PATH_CACHE', getenv('RSSBRIDGE_DATA') . '/cache/');
|
||||
|
||||
// Allow larger files for simple_html_dom
|
||||
// todo: extract to config (if possible)
|
||||
@@ -43,7 +43,7 @@
|
||||
});
|
||||
|
||||
$customConfig = [];
|
||||
-if (file_exists(__DIR__ . '/../config.ini.php')) {
|
||||
- $customConfig = parse_ini_file(__DIR__ . '/../config.ini.php', true, INI_SCANNER_TYPED);
|
||||
+if (file_exists(getenv('RSSBRIDGE_DATA') . '/config.ini.php')) {
|
||||
+ $customConfig = parse_ini_file(getenv('RSSBRIDGE_DATA') . '/config.ini.php', true, INI_SCANNER_TYPED);
|
||||
}
|
||||
Configuration::loadConfiguration($customConfig, getenv());
|
Loading…
Reference in New Issue
Block a user