about summary refs log tree commit diff
path: root/pkgs/servers
diff options
context:
space:
mode:
authorMynacol <Mynacol@users.noreply.github.com>2023-10-16 21:19:03 +0200
committerYaya <github@uwu.is>2023-10-22 22:19:46 +0200
commitc2c5d261ab70892234ab72302d01158585795c99 (patch)
tree062dc00e3d338db9fa1bbc1969b7db29d5d616c3 /pkgs/servers
parente9ea06e57fec8b0ebb8dce718ef6a4bc2f0b9446 (diff)
rss-bridge: Move substitutions into patch file
As requested in https://github.com/NixOS/nixpkgs/pull/257641#pullrequestreview-1678477898
Diffstat (limited to 'pkgs/servers')
-rw-r--r--pkgs/servers/web-apps/rss-bridge/default.nix11
-rw-r--r--pkgs/servers/web-apps/rss-bridge/paths.patch43
2 files changed, 46 insertions, 8 deletions
diff --git a/pkgs/servers/web-apps/rss-bridge/default.nix b/pkgs/servers/web-apps/rss-bridge/default.nix
index cf32bfdabf427..64dbce3b76157 100644
--- a/pkgs/servers/web-apps/rss-bridge/default.nix
+++ b/pkgs/servers/web-apps/rss-bridge/default.nix
@@ -11,14 +11,9 @@ stdenv.mkDerivation rec {
     sha256 = "sha256-N1pbveOgJrB1M+WelKD07Jmv9Vz5NqT+IJf//L8UEnU=";
   };
 
-  postPatch = ''
-    substituteInPlace lib/RssBridge.php \
-        --replace "__DIR__ . '/../config.ini.php'" "getenv('RSSBRIDGE_DATA') . '/config.ini.php'"
-    substituteInPlace lib/bootstrap.php \
-        --replace "const PATH_CACHE = __DIR__ . '/../cache/';" "define('PATH_CACHE', getenv('RSSBRIDGE_DATA') . '/cache/');"
-    substituteInPlace lib/Configuration.php \
-        --replace "__DIR__ . '/../whitelist.txt'" "getenv('RSSBRIDGE_DATA') . '/whitelist.txt'"
-  '';
+  patches = [
+    ./paths.patch
+  ];
 
   installPhase = ''
     mkdir $out/
diff --git a/pkgs/servers/web-apps/rss-bridge/paths.patch b/pkgs/servers/web-apps/rss-bridge/paths.patch
new file mode 100644
index 0000000000000..b226676cb28a0
--- /dev/null
+++ b/pkgs/servers/web-apps/rss-bridge/paths.patch
@@ -0,0 +1,43 @@
+diff --git a/lib/Configuration.php b/lib/Configuration.php
+index c38d7cc9..d95e5174 100644
+--- a/lib/Configuration.php
++++ b/lib/Configuration.php
+@@ -104,8 +104,8 @@ final class Configuration
+             }
+         }
+ 
+-        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/RssBridge.php b/lib/RssBridge.php
+index 6ba952eb..a0bbaf03 100644
+--- a/lib/RssBridge.php
++++ b/lib/RssBridge.php
+@@ -11,8 +11,8 @@ final class RssBridge
+         Configuration::verifyInstallation();
+ 
+         $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());
+ 
+diff --git a/lib/bootstrap.php b/lib/bootstrap.php
+index dc1c0f04..194a3f8f 100644
+--- a/lib/bootstrap.php
++++ b/lib/bootstrap.php
+@@ -27,7 +27,7 @@ const PATH_LIB_CACHES = __DIR__ . '/../caches/';
+ const PATH_LIB_ACTIONS = __DIR__ . '/../actions/';
+ 
+ /** Path to the cache folder */
+-const PATH_CACHE = __DIR__ . '/../cache/';
++define('PATH_CACHE', getenv('RSSBRIDGE_DATA') . '/cache/');
+ 
+ /** URL to the RSS-Bridge repository */
+ const REPOSITORY = 'https://github.com/RSS-Bridge/rss-bridge/';