2022-10-10 13:03:08 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: let
|
2021-04-22 22:32:54 +01:00
|
|
|
minecraft-server-args = [
|
|
|
|
"-Xms2G"
|
|
|
|
"-Xmx2G"
|
|
|
|
"-Dsun.rmi.dgc.server.gcInterval=2157583646"
|
|
|
|
"-XX:+UseG1GC"
|
|
|
|
"-XX:+ParallelRefProcEnabled"
|
|
|
|
"-XX:MaxGCPauseMillis=200"
|
|
|
|
"-XX:+UnlockExperimentalVMOptions"
|
|
|
|
"-XX:+DisableExplicitGC"
|
|
|
|
"-XX:+AlwaysPreTouch"
|
|
|
|
"-XX:G1NewSizePercent=30"
|
|
|
|
"-XX:G1MaxNewSizePercent=40"
|
|
|
|
"-XX:G1HeapRegionSize=8M"
|
|
|
|
"-XX:G1ReservePercent=20"
|
|
|
|
"-XX:G1HeapWastePercent=5"
|
|
|
|
"-XX:G1MixedGCCountTarget=4"
|
|
|
|
"-XX:InitiatingHeapOccupancyPercent=15"
|
|
|
|
"-XX:G1MixedGCLiveThresholdPercent=90"
|
|
|
|
"-XX:G1RSetUpdatingPauseTimePercent=5"
|
|
|
|
"-XX:SurvivorRatio=32"
|
|
|
|
"-XX:+PerfDisableSharedMem"
|
|
|
|
"-XX:MaxTenuringThreshold=1"
|
|
|
|
];
|
2022-10-10 13:03:08 +01:00
|
|
|
ops = pkgs.writeText "ops.json" (builtins.toJSON [
|
|
|
|
{
|
|
|
|
uuid = "140d177a-966f-41b8-a4c0-e305babd291b";
|
|
|
|
name = "TLATER";
|
|
|
|
level = 4;
|
|
|
|
bypassesPlayerLimit = true;
|
|
|
|
}
|
|
|
|
]);
|
2021-04-22 22:32:54 +01:00
|
|
|
whitelist = pkgs.writeText "whitelist.json" (builtins.toJSON [
|
|
|
|
{
|
|
|
|
uuid = "59cd1648-14a4-4bcf-8f5a-2e1bde678f2c";
|
|
|
|
name = "romino25";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
uuid = "0ab6e3d1-544a-47e7-8538-2e6c248e49a4";
|
|
|
|
name = "lasi25";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
uuid = "01c9e737-fc9d-4d55-b8c2-610ca80eb4be";
|
|
|
|
name = "Nampeyo25";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
uuid = "140d177a-966f-41b8-a4c0-e305babd291b";
|
|
|
|
name = "tlater";
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
eula = pkgs.writeText "eula.txt" "eula=true";
|
|
|
|
in {
|
2021-12-26 19:00:59 +00:00
|
|
|
users = {
|
|
|
|
extraUsers.minecraft = {
|
|
|
|
uid = config.ids.uids.minecraft;
|
|
|
|
group = config.users.extraGroups.minecraft.name;
|
|
|
|
isSystemUser = true;
|
|
|
|
description = "Minecraft server user";
|
|
|
|
};
|
2022-10-10 13:03:08 +01:00
|
|
|
extraGroups.minecraft = {gid = config.ids.gids.minecraft;};
|
2021-12-26 19:00:59 +00:00
|
|
|
};
|
|
|
|
|
2021-04-25 05:13:57 +01:00
|
|
|
virtualisation.oci-containers.containers.minecraft-voor-kia = let
|
|
|
|
properties = ./configs/minecraft/voor-kia/server.properties;
|
|
|
|
icon = ./configs/minecraft/voor-kia/server-icon.png;
|
|
|
|
in {
|
|
|
|
image = "tlaternet/minecraft-voor-kia";
|
2021-04-22 22:32:54 +01:00
|
|
|
|
2021-04-25 05:13:57 +01:00
|
|
|
imageFile = pkgs.dockerTools.buildImage {
|
|
|
|
name = "tlaternet/minecraft-voor-kia";
|
|
|
|
tag = "latest";
|
|
|
|
contents = [
|
|
|
|
(pkgs.local.forge-server.override {
|
|
|
|
jre_headless = pkgs.jdk11_headless;
|
|
|
|
mods = pkgs.local.voor-kia;
|
2021-04-25 21:05:47 +01:00
|
|
|
modConfig = ./configs/minecraft/voor-kia/config;
|
2021-04-25 05:13:57 +01:00
|
|
|
defaultconfigs = ./configs/minecraft/voor-kia/defaultconfigs;
|
|
|
|
})
|
|
|
|
];
|
2021-04-22 22:32:54 +01:00
|
|
|
|
2021-04-25 05:13:57 +01:00
|
|
|
config = let
|
2021-12-26 19:00:59 +00:00
|
|
|
uid = toString config.users.extraUsers.minecraft.uid;
|
|
|
|
gid = toString config.users.extraGroups.minecraft.gid;
|
2021-04-25 05:13:57 +01:00
|
|
|
in {
|
2022-10-10 13:03:08 +01:00
|
|
|
Cmd = ["forge-server"] ++ minecraft-server-args;
|
2021-04-25 05:13:57 +01:00
|
|
|
WorkingDir = "/var/lib/minecraft";
|
|
|
|
Volumes = {
|
2022-10-10 13:03:08 +01:00
|
|
|
"/var/lib/minecraft" = {};
|
2021-04-25 05:13:57 +01:00
|
|
|
# Required because some things will try to write to /tmp,
|
|
|
|
# which doesn't exist if it's not defined as a volume.
|
2022-10-10 13:03:08 +01:00
|
|
|
"/tmp" = {};
|
2021-04-22 22:32:54 +01:00
|
|
|
};
|
2022-10-10 13:03:08 +01:00
|
|
|
ExposedPorts = {"25565" = {};};
|
2021-04-25 05:13:57 +01:00
|
|
|
User = "${uid}:${gid}";
|
2021-04-22 22:32:54 +01:00
|
|
|
};
|
|
|
|
};
|
2021-04-25 05:13:57 +01:00
|
|
|
|
2022-10-10 13:03:08 +01:00
|
|
|
extraOptions = ["--cpus=1.0"];
|
2021-04-25 05:13:57 +01:00
|
|
|
autoStart = false;
|
2022-10-10 13:03:08 +01:00
|
|
|
ports = ["25565:25565"];
|
2021-04-25 05:13:57 +01:00
|
|
|
volumes = [
|
|
|
|
"minecraft:/var/lib/minecraft"
|
|
|
|
"${eula}:/var/lib/minecraft/eula.txt:ro"
|
|
|
|
"${icon}:/var/lib/minecraft/server-icon.png:ro"
|
|
|
|
"${ops}:/var/lib/minecraft/ops.json:ro"
|
|
|
|
"${properties}:/var/lib/minecraft/server.properties:ro"
|
|
|
|
"${whitelist}:/var/lib/minecraft/whitelist.json:ro"
|
|
|
|
];
|
|
|
|
};
|
2021-08-27 18:10:19 +01:00
|
|
|
|
|
|
|
systemd.timers.podman-minecraft-voor-kia-off = {
|
|
|
|
description = "Turns off the minecraft server every day at 4 am";
|
2022-10-10 13:03:08 +01:00
|
|
|
wantedBy = ["podman-minecraft-voor-kia.service"];
|
2021-08-27 18:10:19 +01:00
|
|
|
timerConfig = {
|
|
|
|
Unit = "podman-minecraft-voor-kia-starter@stop.service";
|
|
|
|
OnCalendar = "04:00:00";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.timers.podman-minecraft-voor-kia-on = {
|
|
|
|
description = "Turns on the minecraft server every day at 2 pm";
|
2022-10-10 13:03:08 +01:00
|
|
|
wantedBy = ["podman-minecraft-voor-kia.service"];
|
2021-08-27 18:10:19 +01:00
|
|
|
timerConfig = {
|
|
|
|
Unit = "podman-minecraft-voor-kia-starter@start.service";
|
|
|
|
OnCalendar = "14:00:00";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services."podman-minecraft-voor-kia-starter@" = {
|
|
|
|
description = "Unit to stop/start the minecraft server";
|
|
|
|
serviceConfig = {
|
2022-10-10 13:03:08 +01:00
|
|
|
ExecStart = "${pkgs.systemd}/bin/systemctl %i podman-minecraft-voor-kia.service";
|
2021-08-27 18:10:19 +01:00
|
|
|
Type = "oneshot";
|
|
|
|
};
|
|
|
|
};
|
2021-04-22 22:32:54 +01:00
|
|
|
}
|