Unverified Commit 0538ecd0 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

rss-bridge: Remove pkg patch, adapt nixos service (#331295)

parents 91e4123f aa0fc3e8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -489,6 +489,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`.
+28 −15
Original line number Diff line number Diff line
@@ -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 = {

    systemd.tmpfiles.settings.rss-bridge = {
      "${cfg.config.FileCache.path}".d = {
          mode = "0750";
          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) {
@@ -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}
            '';
          };
+0 −4
Original line number Diff line number Diff line
@@ -11,10 +11,6 @@ stdenv.mkDerivation rec {
    sha256 = "sha256-VycEgu7uHYwDnNE1eoVxgaWZAnC6mZLBxT8Le3PI4Rs=";
  };

  patches = [
    ./paths.patch
  ];

  installPhase = ''
    mkdir $out/
    cp -R ./* $out
+0 −38
Original line number Diff line number Diff line
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());