From aa0fc3e8b872cdaa02a53e878f7392d7d87ca836 Mon Sep 17 00:00:00 2001 From: Mynacol Date: Wed, 31 Jul 2024 14:38:43 +0200 Subject: [PATCH] rss-bridge: Remove pkg patch, adapt nixos service The rss-bridge service changes introduced in f2201789fe442282c7ec17c225a9a78dd1973a09 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. --- .../manual/release-notes/rl-2411.section.md | 3 ++ .../modules/services/web-apps/rss-bridge.nix | 43 ++++++++++++------- pkgs/servers/web-apps/rss-bridge/default.nix | 4 -- pkgs/servers/web-apps/rss-bridge/paths.patch | 38 ---------------- 4 files changed, 31 insertions(+), 57 deletions(-) delete mode 100644 pkgs/servers/web-apps/rss-bridge/paths.patch diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index f9a5846c1f38..3d1e929205ed 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -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`. diff --git a/nixos/modules/services/web-apps/rss-bridge.nix b/nixos/modules/services/web-apps/rss-bridge.nix index b03c7f7e8069..9c22b72d31cd 100644 --- a/nixos/modules/services/web-apps/rss-bridge.nix +++ b/nixos/modules/services/web-apps/rss-bridge.nix @@ -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} ''; }; diff --git a/pkgs/servers/web-apps/rss-bridge/default.nix b/pkgs/servers/web-apps/rss-bridge/default.nix index b44ebf088eab..34296541fdf5 100644 --- a/pkgs/servers/web-apps/rss-bridge/default.nix +++ b/pkgs/servers/web-apps/rss-bridge/default.nix @@ -11,10 +11,6 @@ stdenv.mkDerivation rec { sha256 = "sha256-VycEgu7uHYwDnNE1eoVxgaWZAnC6mZLBxT8Le3PI4Rs="; }; - patches = [ - ./paths.patch - ]; - installPhase = '' mkdir $out/ cp -R ./* $out diff --git a/pkgs/servers/web-apps/rss-bridge/paths.patch b/pkgs/servers/web-apps/rss-bridge/paths.patch deleted file mode 100644 index 21747a381bd6..000000000000 --- a/pkgs/servers/web-apps/rss-bridge/paths.patch +++ /dev/null @@ -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 @@ -