summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorQuentin Aristote <quentin@aristote.fr>2022-12-20 22:29:55 +0100
committerQuentin Aristote <quentin@aristote.fr>2022-12-20 22:29:55 +0100
commit95644485ac1402a8dc84c520a3ded7b29720f950 (patch)
treec124a795dba03106cadff1645c532f6251898f86 /modules
parent51df83cffaa45130f94bf5ab78b6b14fbb37ec4d (diff)
parent9bde3c4624eb916bafcf9a18792edb42e3a25a17 (diff)
Merge branch 'master' into searx-engine-alternativeto
Diffstat (limited to 'modules')
-rw-r--r--modules/default.nix1
-rw-r--r--modules/rss-bridge.nix71
2 files changed, 72 insertions, 0 deletions
diff --git a/modules/default.nix b/modules/default.nix
index d09a8c0..95f75b4 100644
--- a/modules/default.nix
+++ b/modules/default.nix
@@ -3,5 +3,6 @@
{
imports = [
./filtron.nix
+ ./rss-bridge.nix
];
}
diff --git a/modules/rss-bridge.nix b/modules/rss-bridge.nix
new file mode 100644
index 0000000..7c0d349
--- /dev/null
+++ b/modules/rss-bridge.nix
@@ -0,0 +1,71 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+ cfg = config.services.rss-bridge;
+ rss-bridge = pkgs.rss-bridge.overrideAttrs (oldAttrs:
+ oldAttrs // {
+ installPhase = oldAttrs.installPhase + ''
+ pushd $out/bridges
+ ln -sf ${./ParisJazzClubBridge.php} ParisJazzClubBridge.php
+ ln -sf ${./MaisonDeLaRadioBridge.php} MaisonDeLaRadioBridge.php
+ ln -sf ${./FipAlbumsBridge.php} FipAlbumsBridge.php
+ ln -sf ${./WhatsOnMubiBridge.php} WhatsOnMubiBridge.php
+ popd
+ '' + lib.optionalString debug ''
+ touch $out/DEBUG
+ '';
+ });
+in {
+ options.services.rss-bridge = {
+ package = mkOption {
+ type = types.package;
+ description = "Which derivation to use.";
+ default = pkgs.rss-bridge;
+ defaultText = literalExample "pkgs.rss-bridge";
+ };
+ debug = mkEnableOption "debug mode";
+ extraBridges = mkOption {
+ type = types.listOf (types.submodule {
+ options = {
+ name = mkOption {
+ type = types.strMatching "[a-zA-Z0-9]*";
+ description = ''
+ The name of the bridge.
+ It need not include 'Bridge' at the end, unlike required in RSS-Bridge.
+ '';
+ example = "SomeAppWithANewsletter";
+ };
+ source = mkOption {
+ type = types.path;
+ description = ''
+ The path to a file whose contents is the PHP sourcecode of the bridge.
+ See also the RSS-Bridge documentation: https://rss-bridge.github.io/rss-bridge/Bridge_API/index.html.
+ '';
+ };
+ };
+ });
+ default = [ ];
+ description = ''
+ A list of additional bridges that aren't already included in RSS-Bridge.
+ These bridges are automatically whitelisted'';
+ };
+ };
+
+ config.services.rss-bridge.whitelist =
+ map (bridge: bridge.name) cfg.extraBridges;
+ config.services.nginx = mkIf (cfg.virtualHost != null) {
+ virtualHosts.${cfg.virtualHost}.root = mkIf (cfg.extraBridges != [ ])
+ (mkForce (pkgs.runCommand "rss-bridge" { } (''
+ mkdir -p $out/bridges
+ cp -r ${cfg.package}/* $out/
+ pushd $out/bridges
+ '' + concatStrings (map (bridge: ''
+ ln -sf ${bridge.source} "${bridge.name}Bridge.php"
+ '') cfg.extraBridges) + ''
+ popd
+ '' + lib.optionalString cfg.debug ''
+ touch $out/DEBUG
+ '')));
+ };
+}