summaryrefslogtreecommitdiff
path: root/modules/nixos/rss-bridge.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/nixos/rss-bridge.nix')
-rw-r--r--modules/nixos/rss-bridge.nix91
1 files changed, 50 insertions, 41 deletions
diff --git a/modules/nixos/rss-bridge.nix b/modules/nixos/rss-bridge.nix
index 5a938d8..2f90af7 100644
--- a/modules/nixos/rss-bridge.nix
+++ b/modules/nixos/rss-bridge.nix
@@ -3,58 +3,67 @@
lib,
pkgs,
...
-}: let
+}:
+let
cfg = config.services.rss-bridge;
-in {
+in
+{
options.services.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.
- '';
+ 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 = [];
+ }
+ );
+ default = [ ];
description = ''
A list of additional bridges that aren't already included in RSS-Bridge.
These bridges are automatically whitelisted'';
};
};
- config.services.rss-bridge.config.system.enabled_bridges =
- lib.mkIf cfg.enable
- (map (bridge: bridge.name) cfg.extraBridges);
+ config.services.rss-bridge.config.system.enabled_bridges = lib.mkIf cfg.enable (
+ 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
- '')));
+ 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
+ ''
+ )
+ )
+ );
};
}