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 = {
forceSSL = true;
useACMEHost = "skynet"; # https://config.minecraft.games.skynet.ie
locations."/map/".alias = "/etc/games/minecraft/compsoc/classic/config/plugins/dynmap/web/"; "config.${short_domain}" = {
forceSSL = true;
useACMEHost = "skynet";
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 = {
image = "itzg/mc-router:1.18.0"; mc_proxy.service = {
ports = [ "25565:25565/tcp" ]; image = "itzg/mc-router:1.18.0";
expose = [ "25565" ]; ports = [ "25565:25565/tcp" ];
command = [ expose = [ "25565" ];
"--mapping=compsoc_classic.minecraft.games.skynet.ie=172.17.0.1:20000,compsoc.minecraft.games.skynet.ie=172.17.0.1:20001" command = [
]; "--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 = {
image = "nimmis/spigot:latest";
# setting these here as they arent special
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/classic/config:/minecraft" ];
ports = [
"20000:25565/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 mc_config.service = {
volumes = [ "/etc/games/minecraft/compsoc/current/config:/minecraft" ]; image = "registry.gitlab.com/crafty-controller/crafty-4:4.1.1";
ports = [ environment = {
"20001:25565/tcp" TZ="Etc/UTC";
]; };
volumes = [
"/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 = [
# this ius https only
"8443:8443/tcp"
# compsoc classic
"20000:20000/tcp"
# compsoc
"20001:20001/tcp"
# games
"20002:20002/tcp"
];
};
}; };
}; };
}; };