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/filtron.nix | |
| parent | 262ad5ace2500d97ee3015aee7655f5893801153 (diff) | |
add filtron and rss-bridge modules
Diffstat (limited to 'modules/nixos/filtron.nix')
| -rw-r--r-- | modules/nixos/filtron.nix | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/modules/nixos/filtron.nix b/modules/nixos/filtron.nix new file mode 100644 index 0000000..31d77e9 --- /dev/null +++ b/modules/nixos/filtron.nix @@ -0,0 +1,86 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.services.filtron; + addressType = lib.types.submodule { + options = { + address = lib.mkOption { + type = lib.types.str; + default = "127.0.0.1"; + }; + port = lib.mkOption { type = lib.types.port; }; + }; + }; +in { + options.services.filtron = { + enable = lib.mkEnableOption "filtron"; + package = lib.mkOption { + type = lib.types.package; + default = pkgs.personal.filtron; + defaultText = lib.literalExample "pkgs.personal.filtron"; + description = '' + The package containing the filtron executable. + ''; + }; + api = lib.mkOption { + type = addressType; + default = { address = "localhost"; port = 4005; }; + description = '' + API listen address and port. + ''; + }; + listen = lib.mkOption { + type = addressType; + default = { port = 4004; }; + description = '' + Proxy listen address and port. + ''; + }; + target = lib.mkOption { + type = addressType; + default = { port = 8888; }; + description = '' + Target address and port for reverse proxy. + ''; + }; + rules = lib.mkOption { + type = with lib.types; listOf (attrsOf anything); + description = '' + Rule list. + ''; + }; + readBufferSize = lib.mkOption { + type = lib.types.int; + default = 16384; + description = '' + Size of the buffer used for reading. + ''; + }; + }; + + config = lib.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} + ''; + }; + }; + }; +} |
