feat: setup minecraft for both us and gsoc

This commit is contained in:
silver 2023-06-11 22:11:57 +01:00
parent d3dba7891d
commit 883a6b239c

View file

@ -2,6 +2,8 @@
with lib; with lib;
let let
cfg = config.services.skynet_games_minecraft; cfg = config.services.skynet_games_minecraft;
short_domain = "${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}";
in { in {
imports = [ imports = [
@ -52,29 +54,43 @@
skynet_dns.records = { skynet_dns.records = {
external = []; external = [];
cname = [ cname = [
"config.${cfg.domain.sub} CNAME ${cfg.host.name}"
# create a sub-subdomain for each game # create a sub-subdomain for each game
# compsoc_classic.minecraft.games.skynet.ie
"compsoc_classic.${cfg.domain.sub} CNAME ${cfg.host.name}" "compsoc_classic.${cfg.domain.sub} CNAME ${cfg.host.name}"
"compsoc.${cfg.domain.sub} CNAME ${cfg.host.name}" "compsoc.${cfg.domain.sub} CNAME ${cfg.host.name}"
"map.compsoc_classic.${cfg.domain.sub} CNAME ${cfg.host.name}" # gsoc.minecraft.games.skynet.ie
#"compsoc.minecraft.games CNAME games" "gsoc.${cfg.domain.sub} CNAME ${cfg.host.name}"
]; ];
}; };
networking.firewall.allowedTCPPorts = [ networking.firewall.allowedTCPPorts = [
# for the proxy # for the proxy
25565 25565
# the servers
20000
20001
]; ];
services.nginx.virtualHosts."compsoc_classic.${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}" = { services.nginx.virtualHosts = {
# https://config.minecraft.games.skynet.ie
"config.${short_domain}" = {
forceSSL = true; forceSSL = true;
useACMEHost = "skynet"; useACMEHost = "skynet";
locations."/map/".alias = "/etc/games/minecraft/compsoc/classic/config/plugins/dynmap/web/"; locations."/" = {
proxyPass = "https://localhost:8443";
proxyWebsockets = true;
};
};
# https://compsoc_classic.minecraft.games.skynet.ie/map/
"compsoc_classic.${short_domain}" = {
forceSSL = true;
useACMEHost = "skynet";
locations."/map/".alias = "/etc/games/minecraft/craftycontrol/servers/f4c5eb33-c6d6-421c-81ab-ded31f6e8750/plugins/dynmap/web/";
};
}; };
# arion is one way to use docker on nixos # arion is one way to use docker on nixos
@ -84,46 +100,42 @@
backend = "docker"; backend = "docker";
projects = { projects = {
minecraft_proxy.settings.services.mc_proxy.service = { minecraft.settings.services = {
mc_proxy.service = {
image = "itzg/mc-router:1.18.0"; image = "itzg/mc-router:1.18.0";
ports = [ "25565:25565/tcp" ]; ports = [ "25565:25565/tcp" ];
expose = [ "25565" ]; expose = [ "25565" ];
command = [ command = [
"--mapping=compsoc_classic.minecraft.games.skynet.ie=172.17.0.1:20000,compsoc.minecraft.games.skynet.ie=172.17.0.1:20001" "--mapping=compsoc_classic.${short_domain}=mc_config:20000,compsoc.${short_domain}=mc_config:20001,gsoc.${short_domain}=mc_config:20002"
]; ];
}; };
minecraft_compsoc_classic.settings.services.compsoc_classic.service = { mc_config.service = {
image = "nimmis/spigot:latest"; image = "registry.gitlab.com/crafty-controller/crafty-4:4.1.1";
# setting these here as they arent special
environment = { environment = {
# this is what it last ran on TZ="Etc/UTC";
SPIGOT_VER="1.18.2";
EULA="true";
}; };
# where the config files are stored volumes = [
volumes = [ "/etc/games/minecraft/compsoc/classic/config:/minecraft" ]; "/etc/games/minecraft/craftycontrol/backups:/crafty/backups"
"/etc/games/minecraft/craftycontrol/logs:/crafty/logs"
"/etc/games/minecraft/craftycontrol/servers:/crafty/servers"
"/etc/games/minecraft/craftycontrol/config:/crafty/app/config"
"/etc/games/minecraft/craftycontrol/import:/crafty/import"
];
ports = [ ports = [
"20000:25565/tcp" # this ius https only
"8443:8443/tcp"
# compsoc classic
"20000:20000/tcp"
# compsoc
"20001:20001/tcp"
# games
"20002:20002/tcp"
]; ];
}; };
minecraft_compsoc.settings.services.compsoc_test.service = {
image = "nimmis/spigot:latest";
environment = {
# this is what it last ran on
SPIGOT_VER="1.18.2";
EULA="true";
};
# where the config files are stored
volumes = [ "/etc/games/minecraft/compsoc/current/config:/minecraft" ];
ports = [
"20001:25565/tcp"
];
}; };
}; };
}; };