flake/systems/etna/minecraft.nix

64 lines
1.3 KiB
Nix
Raw Normal View History

2024-04-13 14:26:07 +02:00
{
lib,
pkgs,
2024-04-13 14:26:07 +02:00
config,
2024-07-29 10:58:43 +02:00
_utils,
2024-04-13 14:26:07 +02:00
...
}: let
inherit (config.virtualisation.oci-containers) backend;
2024-07-29 10:58:43 +02:00
secret = _utils.setupSingleSecret config "minecraftEnv" {};
2024-07-29 10:58:43 +02:00
atm9 = _utils.mkMinecraftServer config {
name = "atm9";
port = 25565;
remotePort = 6004;
tag = "java17";
memory = "8G";
envFiles = [secret.path];
env = {
USE_AIKAR_FLAGS = "true";
MOD_PLATFORM = "AUTO_CURSEFORGE";
CF_SLUG = "all-the-mods-9";
CF_FILE_ID = "5458414";
};
};
2024-07-29 10:58:43 +02:00
lynn = _utils.mkMinecraftServer config {
name = "lynn";
port = 25567;
remotePort = 6002;
memory = "4G";
envFiles = [secret.path];
env = {
USE_AIKAR_FLAGS = "true";
TYPE = "MODRINTH";
MODRINTH_MODPACK = "https://modrinth.com/modpack/adrenaserver/version/1.6.0+1.20.6.fabric";
};
};
in {
imports = [
secret.generate
2024-07-29 10:58:43 +02:00
atm9
lynn
];
2024-07-29 10:58:43 +02:00
systemd.services.restart-minecraft-servers = {
wantedBy = ["multi-user.target"];
script = ''
${lib.getExe' pkgs.systemd "systemctl"} restart ${backend}-*.service
'';
serviceConfig.Type = "oneshot";
};
2024-07-29 10:58:43 +02:00
systemd.timers.restart-minecraft-servers = {
wantedBy = ["timers.target"];
timerConfig = {
OnCalendar = "*-*-* 05:00:00";
Persistent = true;
Unit = "restart-minecraft-servers.service";
};
2024-07-29 10:58:43 +02:00
};
}