From 2c424fc40ab2c436872081c7450b69c9f1e5ea40 Mon Sep 17 00:00:00 2001 From: Adrian Gunnar Lauterer Date: Wed, 5 Jun 2024 10:39:24 +0200 Subject: [PATCH] added minecraft proxy --- machines/elrond/configuration.nix | 1 + services/gate.nix | 44 +++++++++++++++++++++++++++++++ services/mc.nix | 3 --- 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 services/gate.nix diff --git a/machines/elrond/configuration.nix b/machines/elrond/configuration.nix index d1db66b..c692320 100644 --- a/machines/elrond/configuration.nix +++ b/machines/elrond/configuration.nix @@ -9,6 +9,7 @@ ./hardware-configuration.nix ../../profiles/webhost.nix ../../profiles/base.nix + ../../services/gate.nix ./routes.nix ]; diff --git a/services/gate.nix b/services/gate.nix new file mode 100644 index 0000000..235be1f --- /dev/null +++ b/services/gate.nix @@ -0,0 +1,44 @@ +{ config, lib, pkgs, ... }: +let + mcPort = 25565; + configurationFile = '' + config: + lite: + enabled: true + routes: + - host: mc.256.no + backend: 100.84.215.84:25565 + ''; + file = pkgs.writeText "gate.yaml" configurationFile; +in +{ + + networking.firewall.allowedTCPPorts = [ mcPort]; + networking.firewall.allowedUDPPorts = [ mcPort]; + + users.users.gate = { + isSystemUser = true; + description = "Gate Minecraft Proxy User"; + home = "/var/lib/gate"; + createHome = true; + group = "gate"; + }; + + users.groups.gate = { + }; + + systemd.services."gate" = { + after = [ "network.target" ]; + wants = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + ExecStart = "${pkgs.gate}/bin/gate -c ${file}"; + User = "gate"; + Group = "gate"; + Restart = "on-failure"; + ProtectKernelModules = true; + NoNewPrivileges = true; + }; + }; +} diff --git a/services/mc.nix b/services/mc.nix index 9fce8f7..427de2d 100644 --- a/services/mc.nix +++ b/services/mc.nix @@ -1,8 +1,5 @@ { config, pkgs, lib, ... }: { - environment.systemPackages = [ - pkgs.ollama - ]; services.minecraft-server = { enable = true;