diff --git a/flake.nix b/flake.nix index 564d0dd..00c257b 100755 --- a/flake.nix +++ b/flake.nix @@ -39,6 +39,8 @@ ./services/spacebar.nix ./services/rgit.nix + ./services/translate.nix + noshell.nixosModules.default {programs.noshell.enable = true;} diff --git a/services/ferron.nix b/services/ferron.nix index 939a5d8..c300d29 100755 --- a/services/ferron.nix +++ b/services/ferron.nix @@ -33,6 +33,11 @@ domain = "spacebar-api.mtgmonkey.net"; proxyTo = "http://localhost:3001/"; } + { + domain = "translate.mtgmonkey.net"; + proxyTo = "http://localhost:9109/" + } + ]; }; in { diff --git a/services/translate.nix b/services/translate.nix new file mode 100755 index 0000000..f9be6c0 --- /dev/null +++ b/services/translate.nix @@ -0,0 +1,48 @@ +{ + pkgs, + lib, + ... +}: let + botPolicies-nix = { + dnsbl = false; + status_codes = { + CHALLENGE = 200; + DENY = 200; + }; + bots = [ + { + name = "catch-everything"; + user_agent_regex = ".*"; + action = "CHALLENGE"; + } + ]; + }; +in { + services.anubis = { + instances.translate = { + enable = true; + settings = { + BIND = "[::1]:9109"; + BIND_NETWORK = "tcp"; + DIFFICULTY = 4; + METRICS_BIND = "[::1]:9119"; + METRICS_BIND_NETWORK = "tcp"; + POLICY_FNAME = "/etc/anubis/elmskell.botPolicies.yaml"; + TARGET = "http://localhost:8108"; + }; + }; + }; + + environment.etc."anubis/translate.botPolicies.yaml" = { + source = (pkgs.formats.yaml {}).generate "" botPolicies-nix; + mode = "644"; + }; + + systemd.services.translate = { + serviceConfig = { + Type = "simple"; + ExecStart = "${lib.getExe pkgs.libretranslate}"; + RemainAfterExit = true; + }; + }; +}