Tristan Daniël Maat
c434f513cd
This needs to be done because the server does not support qemu, and NixOS requires qemu to use the runAsRoot feature for docker images. Instead, create the required files as part of the entrypoint. Fixes #6
130 lines
3.7 KiB
Nix
130 lines
3.7 KiB
Nix
{ pkgs, ... }:
|
|
|
|
let
|
|
entrypoint = pkgs.writeScript "entrypoint.sh" ''
|
|
#!${pkgs.bash}/bin/bash
|
|
${pkgs.busybox}/bin/mkdir -p /var/lib/
|
|
${pkgs.gzip}/bin/gzip -dc ${./configs/minecraft.tar.gz} | ${pkgs.gnutar}/bin/tar -xf - -C /var/lib
|
|
echo 'eula=true' > /var/lib/minecraft/eula.txt
|
|
cp -f ${properties} /var/lib/minecraft
|
|
$@
|
|
'';
|
|
ops = pkgs.writeText "ops.json" (builtins.toJSON [
|
|
{
|
|
uuid = "140d177a-966f-41b8-a4c0-e305babd291b";
|
|
name = "TLATER";
|
|
level = 4;
|
|
bypassesPlayerLimit = true;
|
|
}
|
|
]);
|
|
whitelist = pkgs.writeText "whitelist.json" (builtins.toJSON [
|
|
{
|
|
uuid = "59cd1648-14a4-4bcf-8f5a-2e1bde678f2c";
|
|
name = "romino25";
|
|
}
|
|
{
|
|
uuid = "0ab6e3d1-544a-47e7-8538-2e6c248e49a4";
|
|
name = "lasi25";
|
|
}
|
|
{
|
|
uuid = "140d177a-966f-41b8-a4c0-e305babd291b";
|
|
name = "TLATER";
|
|
}
|
|
]);
|
|
properties = pkgs.writeText "server.properties" ''
|
|
#Minecraft server properties
|
|
#Sun Jul 19 16:04:54 GMT 2020
|
|
max-tick-time=60000
|
|
generator-settings=
|
|
allow-nether=true
|
|
force-gamemode=false
|
|
gamemode=0
|
|
enable-query=false
|
|
player-idle-timeout=0
|
|
difficulty=1
|
|
spawn-monsters=true
|
|
op-permission-level=4
|
|
pvp=false
|
|
snooper-enabled=true
|
|
level-type=DEFAULT
|
|
hardcore=false
|
|
enable-command-block=false
|
|
max-players=4
|
|
network-compression-threshold=256
|
|
resource-pack-sha1=
|
|
max-world-size=29999984
|
|
server-port=25565
|
|
server-ip=
|
|
spawn-npcs=true
|
|
allow-flight=true
|
|
level-name=world
|
|
view-distance=15
|
|
resource-pack=
|
|
spawn-animals=true
|
|
white-list=true
|
|
generate-structures=true
|
|
online-mode=true
|
|
max-build-height=256
|
|
level-seed=
|
|
prevent-proxy-connections=false
|
|
use-native-transport=true
|
|
motd=Adventures met die broers
|
|
enable-rcon=false
|
|
'';
|
|
|
|
in
|
|
{
|
|
docker-containers = {
|
|
minecraft = {
|
|
image = "tlaternet/minecraft";
|
|
imageFile = pkgs.dockerTools.buildImage {
|
|
name = "tlaternet/minecraft";
|
|
tag = "latest";
|
|
config = {
|
|
Entrypoint = [ "${entrypoint}" ];
|
|
Cmd = [ "${pkgs.jre_headless}/bin/java"
|
|
"-Xms2G"
|
|
"-Xmx2G"
|
|
# Using recommended flags from https://mcflags.emc.gs
|
|
"-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"
|
|
"-jar"
|
|
"/var/lib/minecraft/forge-1.12.2-14.23.5.2854.jar"
|
|
"nogui"
|
|
];
|
|
Volumes = {
|
|
"/var/lib/minecraft/world" = {};
|
|
};
|
|
WorkingDir = "/var/lib/minecraft";
|
|
ExposedPorts = {
|
|
"25565" = {};
|
|
};
|
|
};
|
|
};
|
|
ports = [
|
|
"25565:25565"
|
|
];
|
|
volumes = [
|
|
"${ops}:/var/lib/minecraft/ops.json:ro"
|
|
"${whitelist}:/var/lib/minecraft/whitelist.json:ro"
|
|
];
|
|
};
|
|
};
|
|
}
|