diff options
| author | Quentin Aristote <quentin@aristote.fr> | 2023-02-17 21:22:14 +0100 |
|---|---|---|
| committer | Quentin Aristote <quentin@aristote.fr> | 2023-02-17 21:24:35 +0100 |
| commit | 1fdbb44df1c3b8c0bab9e36cee3e8167e102efc3 (patch) | |
| tree | 210b87b2addd1cc16f06f5646276215841a30622 /modules/nixos/rss-bridge.nix | |
| parent | 262ad5ace2500d97ee3015aee7655f5893801153 (diff) | |
add filtron and rss-bridge modules
Diffstat (limited to 'modules/nixos/rss-bridge.nix')
| -rw-r--r-- | modules/nixos/rss-bridge.nix | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/modules/nixos/rss-bridge.nix b/modules/nixos/rss-bridge.nix new file mode 100644 index 0000000..8974ae6 --- /dev/null +++ b/modules/nixos/rss-bridge.nix @@ -0,0 +1,56 @@ +{ config, lib, pkgs, ... }: + +let cfg = config.services.rss-bridge; +in { + options.services.rss-bridge = { + package = lib.mkOption { + type = lib.types.package; + description = "Which derivation to use."; + default = pkgs.rss-bridge; + defaultText = lib.literalExample "pkgs.rss-bridge"; + }; + debug = lib.mkEnableOption "debug mode"; + extraBridges = lib.mkOption { + type = lib.types.listOf (lib.types.submodule { + options = { + name = lib.mkOption { + type = lib.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 = lib.mkOption { + type = lib.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 = lib.mkIf (cfg.virtualHost != null) { + virtualHosts.${cfg.virtualHost}.root = lib.mkIf (cfg.extraBridges != [ ]) + (lib.mkForce (pkgs.runCommand "rss-bridge" { } ('' + mkdir -p $out/bridges + cp -r ${cfg.package}/* $out/ + pushd $out/bridges + '' + lib.concatStrings (map (bridge: '' + ln -sf ${bridge.source} "${bridge.name}Bridge.php" + '') cfg.extraBridges) + '' + popd + '' + lib.optionalString cfg.debug '' + touch $out/DEBUG + ''))); + }; +} |
