summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/default.nix8
-rw-r--r--modules/filtron.nix87
-rw-r--r--modules/rss-bridge.nix71
3 files changed, 0 insertions, 166 deletions
diff --git a/modules/default.nix b/modules/default.nix
deleted file mode 100644
index 95f75b4..0000000
--- a/modules/default.nix
+++ /dev/null
@@ -1,8 +0,0 @@
-{ ... }:
-
-{
- imports = [
- ./filtron.nix
- ./rss-bridge.nix
- ];
-}
diff --git a/modules/filtron.nix b/modules/filtron.nix
deleted file mode 100644
index 55374a7..0000000
--- a/modules/filtron.nix
+++ /dev/null
@@ -1,87 +0,0 @@
-{ config, lib, pkgs, ... }:
-
-with lib;
-let
- cfg = config.services.filtron;
- addressType = types.submodule {
- options = {
- address = mkOption {
- type = types.str;
- default = "127.0.0.1";
- };
- port = mkOption { type = types.port; };
- };
- };
-in {
- options.services.filtron = {
- enable = mkEnableOption { name = "filtron"; };
- package = mkOption {
- type = types.package;
- default = pkgs.personal.filtron;
- defaultText = literalExample "pkgs.personal.filtron";
- description = ''
- The package containing the filtron executable.
- '';
- };
- api = mkOption {
- type = addressType;
- default = { address = "localhost"; port = 4005; };
- description = ''
- API listen address and port.
- '';
- };
- listen = mkOption {
- type = addressType;
- default = { port = 4004; };
- description = ''
- Proxy listen address and port.
- '';
- };
- target = mkOption {
- type = addressType;
- default = { port = 8888; };
- description = ''
- Target address and port for reverse proxy.
- '';
- };
- rules = mkOption {
- type = with types; listOf (attrsOf anything);
- description = ''
- Rule list.
- '';
- };
- readBufferSize = mkOption {
- type = types.int;
- default = 16384;
- description = ''
- Size of the buffer used for reading.
- '';
- };
- };
-
- config = mkIf cfg.enable {
- users.users.filtron = {
- description = "Filtron daemon user";
- group = "filtron";
- isSystemUser = true;
- };
- users.groups.filtron = { };
-
- systemd.services.filtron = {
- wantedBy = [ "multi-user.target" ];
- after = [ "network.target" ];
- description = "Start a filtron instance.";
- serviceConfig = {
- User = "filtron";
- ExecStart = with builtins; ''
- ${cfg.package}/bin/filtron \
- -rules ${toFile "filtron-rules.json" (toJSON cfg.rules)} \
- -api "${cfg.api.address}:${toString cfg.api.port}" \
- -listen "${cfg.listen.address}:${toString cfg.listen.port}" \
- -target "${cfg.target.address}:${toString cfg.target.port}" \
- -read-buffer-size ${toString cfg.readBufferSize}
- '';
- };
- };
- };
-}
diff --git a/modules/rss-bridge.nix b/modules/rss-bridge.nix
deleted file mode 100644
index 7c0d349..0000000
--- a/modules/rss-bridge.nix
+++ /dev/null
@@ -1,71 +0,0 @@
-{ 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
- '')));
- };
-}