This neoforge server isn't freaking working

This commit is contained in:
Jimbo 2024-09-17 21:45:44 -04:00
parent c240c3f00d
commit c3ee9a15ed
15 changed files with 3445 additions and 11 deletions

View file

@ -25,7 +25,7 @@
}; };
# Common plugins # Common plugins
symlinks = { paperSymlinks = {
"plugins/Backuper.jar" = builtins.fetchurl { "plugins/Backuper.jar" = builtins.fetchurl {
url = "https://cdn.modrinth.com/data/7cMAqMND/versions/nkcNIvUw/Backuper-3.0.1.jar"; url = "https://cdn.modrinth.com/data/7cMAqMND/versions/nkcNIvUw/Backuper-3.0.1.jar";
sha256 = "081hvs7khd9s8598i59ai8n0idp85rgc89m9hpfajwym9rmy7il4"; sha256 = "081hvs7khd9s8598i59ai8n0idp85rgc89m9hpfajwym9rmy7il4";
@ -58,8 +58,10 @@
url = "https://cdn.modrinth.com/data/9eGKb6K1/versions/nS19YToN/voicechat-bukkit-2.5.20.jar"; url = "https://cdn.modrinth.com/data/9eGKb6K1/versions/nS19YToN/voicechat-bukkit-2.5.20.jar";
sha256 = "023wjx0zxf9rc2x9vsqg398wapz0nlwfs5g6c8pci3qx75i5s4jx"; sha256 = "023wjx0zxf9rc2x9vsqg398wapz0nlwfs5g6c8pci3qx75i5s4jx";
}; };
};
# Config files # Config files
configSymlinks = {
"plugins/Essentials/config.yml" = ./essentialsconfig.yml; "plugins/Essentials/config.yml" = ./essentialsconfig.yml;
"plugins/voicechat/voicechat-server.properties" = ./vcserver.properties; "plugins/voicechat/voicechat-server.properties" = ./vcserver.properties;
}; };

View file

@ -6,6 +6,7 @@
./servers/johnside.nix ./servers/johnside.nix
./servers/blockworld.nix ./servers/blockworld.nix
./servers/uberbeta.nix ./servers/uberbeta.nix
#./servers/freaktards.nix
]; ];
nixpkgs.overlays = [ inputs.nix-minecraft.overlay ]; nixpkgs.overlays = [ inputs.nix-minecraft.overlay ];

View file

@ -5,13 +5,13 @@ in {
enable = true; enable = true;
autoStart = false; autoStart = false;
package = pkgs.paperServers.paper-1_21_1; package = pkgs.paperServers.paper-1_21_1;
jvmOpts = "-Xmx4084M"; jvmOpts = "-Xmx3072M";
serverProperties = common.serverProperties // { serverProperties = common.serverProperties // {
difficulty = 2; difficulty = 2;
server-port = 30012; server-port = 30012;
motd = "§fArchival §l§n§cBloxelcom §r§fMinecraft server."; motd = "§fArchival §l§n§cBloxelcom §r§fMinecraft server.";
}; };
whitelist = common.whitelist; whitelist = common.whitelist;
symlinks = common.symlinks; symlinks = common.paperSymlinks // common.configSymlinks;
}; };
} }

View file

@ -4,13 +4,13 @@ in {
services.minecraft-servers.servers.dewdemolisher = { services.minecraft-servers.servers.dewdemolisher = {
enable = true; enable = true;
package = pkgs.paperServers.paper-1_21_1; package = pkgs.paperServers.paper-1_21_1;
jvmOpts = "-Xmx4084M"; jvmOpts = "-Xmx3072M";
serverProperties = common.serverProperties // { serverProperties = common.serverProperties // {
difficulty = 2; difficulty = 2;
server-port = 30010; server-port = 30010;
motd = "§l§aDew Demolisher is here."; motd = "§l§aDew Demolisher is here.";
}; };
whitelist = common.whitelist; whitelist = common.whitelist;
symlinks = common.symlinks; symlinks = common.paperSymlinks // common.configSymlinks;
}; };
} }

View file

@ -0,0 +1,18 @@
{ pkgs, ... }: let
common = import ../common.nix { inherit pkgs; };
neoForge = pkgs.writeShellScriptBin "minecraft-server" ''
${pkgs.temurin-jre-bin}/bin/java @user_jvm_args.txt @libraries/net/neoforged/neoforge/21.1.51/unix_args.txt "$@"
'';
in {
services.minecraft-servers.servers.freaktards = {
enable = true;
package = neoForge;
serverProperties = common.serverProperties // {
difficulty = 1;
server-port = 30013;
motd = "\\u00A7l\\u00A7o𝓯𝓻𝓮𝓪𝓴\\u00A7r\\u00A7ltards official";
};
whitelist = common.whitelist;
symlinks = common.configSymlinks;
};
}

View file

@ -5,14 +5,14 @@ in {
minecraft-servers.servers.johnside = { minecraft-servers.servers.johnside = {
enable = true; enable = true;
package = pkgs.paperServers.paper-1_20_6; package = pkgs.paperServers.paper-1_20_6;
jvmOpts = "-Xmx4084M"; jvmOpts = "-Xmx3072M";
serverProperties = common.serverProperties // { serverProperties = common.serverProperties // {
difficulty = 2; difficulty = 2;
server-port = 30009; server-port = 30009;
motd = "§l§9Johnside SMP§r §l§fworld for §4John lovers only."; motd = "§l§9Johnside SMP§r §l§fworld for §4John lovers only.";
}; };
whitelist = common.whitelist; whitelist = common.whitelist;
symlinks = common.symlinks // { symlinks = common.paperSymlinks // common.configSymlinks // {
"plugins/BlueMap.jar" = builtins.fetchurl { "plugins/BlueMap.jar" = builtins.fetchurl {
url = "https://cdn.modrinth.com/data/swbUV1cr/versions/TL5ElRWX/BlueMap-5.3-spigot.jar"; url = "https://cdn.modrinth.com/data/swbUV1cr/versions/TL5ElRWX/BlueMap-5.3-spigot.jar";
sha256 = "08ls3wk0333vjg49kcmri884pcgm2xk9xdhwcxyffbh4ra0xrlbw"; sha256 = "08ls3wk0333vjg49kcmri884pcgm2xk9xdhwcxyffbh4ra0xrlbw";

View file

@ -1,7 +1,6 @@
# Custom packages, that can be defined similarly to ones from nixpkgs # Custom packages, that can be defined similarly to nixpkgs
# You can build them using 'nix build .#example'
{pkgs, ...}: { {pkgs, ...}: {
# pkgs
xash3d = pkgs.callPackage ./xash/xash3d.nix {}; xash3d = pkgs.callPackage ./xash/xash3d.nix {};
hlsdk = pkgs.callPackage ./xash/hlsdk.nix {}; hlsdk = pkgs.callPackage ./xash/hlsdk.nix {};
forgeServers = pkgs.callPackage ./forge-servers/default.nix {};
} }

View file

@ -0,0 +1,53 @@
# based on:
# - https://github.com/Infinidoge/nix-minecraft/blob/ab4790259bf8ed20f4417de5a0e5ee592094c7c3/pkgs/fabric-servers/default.nix
# - https://github.com/Faeranne/nix-minecraft/blob/f4e4514f1d65b6a19704eab85070741e40c1d272/pkgs/forge-servers/default.nix
{ callPackage
, lib
, jre8_headless
, jre_headless
}:
with lib;
let
loader_versions = lib.importJSON ./lock_launcher.json;
# Older Minecraft versions that were written for Java 8, required Java 8.
# Mojang has since rewritten a lot of their codebase so that Java versions
# are no longer as important for stability as they used to be. Meaning we can
# target latest the latest JDK for all newer versions of Minecraft.
# TODO: Assert that jre_headless >= java version
getJavaVersion = v: if v == 8 then jre8_headless else jre_headless;
# Copied from https://github.com/Infinidoge/nix-minecraft/blob/ab4790259bf8ed20f4417de5a0e5ee592094c7c3/lib/default.nix
chain = {
func = id;
__functor = self: input:
if (typeOf input) == "lambda"
then self // { func = e: input (self.func e); }
else self.func input;
};
escapeVersion = replaceStrings [ "." " " ] [ "_" "_" ];
isNormalVersion = v: isList (match "([[:digit:]]+\.[[:digit:]]+(\.[[:digit:]]+)?)" v);
latestVersion = versions: chain
(filter isNormalVersion)
(sort versionOlder)
last
(attrNames versions);
#####
mkServer = gameVersion: (callPackage ./server.nix {
inherit gameVersion;
loaderVersion = latestVersion loader_versions.${gameVersion};
jre_headless = getJavaVersion 17;
loaderDrv = ./derivation.nix;
extraJavaArgs = "-Dlog4j.configurationFile=${./log4j.xml}";
});
gameVersions = attrNames loader_versions;
packagesRaw = lib.genAttrs gameVersions mkServer;
packages = lib.mapAttrs' (version: drv: nameValuePair "forge-${escapeVersion version}" drv) packagesRaw;
in
packages

View file

@ -0,0 +1,148 @@
# based on:
# - https://github.com/Faeranne/nix-minecraft/blob/f4e4514f1d65b6a19704eab85070741e40c1d272/pkgs/forge-servers/derivation.nix
# - https://github.com/Infinidoge/nix-minecraft/blob/ab4790259bf8ed20f4417de5a0e5ee592094c7c3/pkgs/build-support/mkTextileLoader.nix
#
# Locks (lock_game.json, lock_launcher.json, lock_libraries.json)
# are copied from https://github.com/Faeranne/nix-minecraft/tree/f4e4514f1d65b6a19704eab85070741e40c1d272/pkgs/forge-servers
#
# Locks are modified to have only one version of Forge (1.20.1-47.3.1)
# I didn't want to deal with many versions of Forge
{ lib
, stdenvNoCC
, fetchurl
, gameVersion
, loaderVersion
, jre_headless
, jq
}:
let
minecraftInfo = (lib.importJSON ./lock_game.json).${gameVersion};
forge-installer = "forge-${gameVersion}-${loaderVersion}-installer";
mappingsInfo = minecraftInfo.mappings;
mappings = fetchurl {
name = "minecraft-mappings";
version = "${gameVersion}";
inherit (mappingsInfo) sha1 url;
};
vanillaInfo = minecraftInfo.server;
vanilla = fetchurl {
name = "vanilla-server";
version = "${gameVersion}";
inherit (vanillaInfo) sha1 url;
};
loader = (lib.importJSON ./lock_launcher.json).${gameVersion}.${loaderVersion};
libraries = minecraftInfo.libraries;
libraries_lock = lib.importJSON ./lock_libraries.json;
fetchedLibraries = lib.forEach libraries (l:
let
library = libraries_lock.${l};
in
fetchurl {
inherit (library) url sha1;
}
);
in
stdenvNoCC.mkDerivation {
pname = "forge-loader";
version = "${gameVersion}-${loaderVersion}";
libraries = fetchedLibraries;
src = fetchurl {
name = forge-installer;
inherit (loader) url;
hash = loader.md5;
};
preferLocalBuild = true;
installPhase = if (loader.type == "installer") then (
let
libraries_path = lib.concatStringsSep " " (lib.forEach libraries (l: libraries_lock.${l}.path));
in
''
LIB_PATHS=(${libraries_path})
mkdir $out
for i in $libraries; do
NIX_LIB=$(basename $i)
NIX_LIB_NAME="''${NIX_LIB:33}"
for l in ''${!LIB_PATHS[@]}; do
LIB="''${LIB_PATHS[$l]}"
LIB_NAME=$(basename $LIB)
if [[ $LIB_NAME == $NIX_LIB_NAME ]]; then
mkdir -p "$out/libraries/$(dirname $LIB)"
ln -s $i $out/libraries/$LIB
echo Linking library: $LIB_NAME
break
fi
done
done
MOJMAP_DIR_NAME=$(basename $out/libraries/de/oceanlabs/mcp/mcp_config/${gameVersion}-*)
echo $MOJMAP_DIR_NAME
MOJMAP_DIR=$out/libraries/net/minecraft/server/$MOJMAP_DIR_NAME
mkdir -p "$MOJMAP_DIR"
ln -s ${mappings} $MOJMAP_DIR/server-$MOJMAP_DIR_NAME-mappings.txt
MINECRAFT_LIB=$out/libraries/net/minecraft/server/${gameVersion}
mkdir -p "$MINECRAFT_LIB"
ln -s ${vanilla} $MINECRAFT_LIB/server-${gameVersion}.jar
cp $src $out/forge-installer.jar
echo Patching forge installer...
pushd $out
${jre_headless}/bin/jar xf $out/forge-installer.jar install_profile.json
mv $out/install_profile.json $out/install_profile_original.json
${lib.getExe jq} 'del(.processors[] | select(.args[1]=="DOWNLOAD_MOJMAPS"))' $out/install_profile_original.json > $out/install_profile.json
mkdir -p $out/META-INF
touch $out/META-INF/FORGE.RSA
${jre_headless}/bin/jar uf $out/forge-installer.jar install_profile.json META-INF/FORGE.RSA
popd
rm $out/install_profile.json
rm $out/install_profile_original.json
rm -rf $out/META-INF
echo Running installer...
${jre_headless}/bin/java -jar $out/forge-installer.jar --offline --installServer $out
echo Cleaning up...
rm $out/run.bat
rm $out/run.sh
rm $out/user_jvm_args.txt
rm $out/forge-installer.jar
substituteInPlace $out/libraries/net/minecraftforge/forge/1.20.1-47.3.1/unix_args.txt \
--replace libraries $out/libraries
'') else throw "Cannot work with other types of packaging than installer!";
dontUnpack = true;
meta = with lib; {
description = "Minecraft Server";
homepage = "https://minecraft.net";
license = licenses.unfreeRedistributable;
platforms = platforms.unix;
maintainers = with maintainers; [ infinidoge ];
mainProgram = "minecraft-server";
};
}

View file

@ -0,0 +1,114 @@
{
"1.21": {
"sha1": "177e49d3233cb6eac42f0495c0a48e719870c2ae",
"server": {
"sha1": "450698d1863ab5180c25d7c804ef0fe6369dd1ba",
"size": 51623779,
"url": "https://piston-data.mojang.com/v1/objects/450698d1863ab5180c25d7c804ef0fe6369dd1ba/server.jar"
},
"mappings": {
"sha1": "31c77994d96f05ba25a870ada70f47f315330437",
"size": 7454609,
"url": "https://piston-data.mojang.com/v1/objects/31c77994d96f05ba25a870ada70f47f315330437/server.txt"
},
"libraries": [
"ca.weblite:java-objc-bridge:1.1",
"com.github.oshi:oshi-core:6.4.10",
"com.google.code.gson:gson:2.10.1",
"com.google.guava:failureaccess:1.0.1",
"com.google.guava:guava:32.1.2-jre",
"com.ibm.icu:icu4j:73.2",
"com.mojang:authlib:6.0.54",
"com.mojang:blocklist:1.0.10",
"com.mojang:brigadier:1.2.9",
"com.mojang:datafixerupper:8.0.16",
"com.mojang:logging:1.2.7",
"com.mojang:patchy:2.2.10",
"com.mojang:text2speech:1.17.9",
"commons-codec:commons-codec:1.16.0",
"commons-io:commons-io:2.15.1",
"commons-logging:commons-logging:1.2",
"io.netty:netty-buffer:4.1.97.Final",
"io.netty:netty-codec:4.1.97.Final",
"io.netty:netty-common:4.1.97.Final",
"io.netty:netty-handler:4.1.97.Final",
"io.netty:netty-resolver:4.1.97.Final",
"io.netty:netty-transport-classes-epoll:4.1.97.Final",
"io.netty:netty-transport-native-epoll:4.1.97.Final:linux-aarch_64",
"io.netty:netty-transport-native-epoll:4.1.97.Final:linux-x86_64",
"io.netty:netty-transport-native-unix-common:4.1.97.Final",
"io.netty:netty-transport:4.1.97.Final",
"it.unimi.dsi:fastutil:8.5.12",
"net.java.dev.jna:jna-platform:5.14.0",
"net.java.dev.jna:jna:5.14.0",
"net.sf.jopt-simple:jopt-simple:5.0.4",
"org.apache.commons:commons-compress:1.26.0",
"org.apache.commons:commons-lang3:3.14.0",
"org.apache.httpcomponents:httpclient:4.5.13",
"org.apache.httpcomponents:httpcore:4.4.16",
"org.apache.logging.log4j:log4j-api:2.22.1",
"org.apache.logging.log4j:log4j-core:2.22.1",
"org.apache.logging.log4j:log4j-slf4j2-impl:2.22.1",
"org.jcraft:jorbis:0.0.17",
"org.joml:joml:1.10.5",
"org.lwjgl:lwjgl-freetype:3.3.3",
"org.lwjgl:lwjgl-freetype:3.3.3:natives-linux",
"org.lwjgl:lwjgl-freetype:3.3.3:natives-macos-arm64",
"org.lwjgl:lwjgl-freetype:3.3.3:natives-macos-patch",
"org.lwjgl:lwjgl-freetype:3.3.3:natives-windows",
"org.lwjgl:lwjgl-freetype:3.3.3:natives-windows-arm64",
"org.lwjgl:lwjgl-freetype:3.3.3:natives-windows-x86",
"org.lwjgl:lwjgl-glfw:3.3.3",
"org.lwjgl:lwjgl-glfw:3.3.3:natives-linux",
"org.lwjgl:lwjgl-glfw:3.3.3:natives-macos",
"org.lwjgl:lwjgl-glfw:3.3.3:natives-macos-arm64",
"org.lwjgl:lwjgl-glfw:3.3.3:natives-windows",
"org.lwjgl:lwjgl-glfw:3.3.3:natives-windows-arm64",
"org.lwjgl:lwjgl-glfw:3.3.3:natives-windows-x86",
"org.lwjgl:lwjgl-jemalloc:3.3.3",
"org.lwjgl:lwjgl-jemalloc:3.3.3:natives-linux",
"org.lwjgl:lwjgl-jemalloc:3.3.3:natives-macos",
"org.lwjgl:lwjgl-jemalloc:3.3.3:natives-macos-arm64",
"org.lwjgl:lwjgl-jemalloc:3.3.3:natives-windows",
"org.lwjgl:lwjgl-jemalloc:3.3.3:natives-windows-arm64",
"org.lwjgl:lwjgl-jemalloc:3.3.3:natives-windows-x86",
"org.lwjgl:lwjgl-openal:3.3.3",
"org.lwjgl:lwjgl-openal:3.3.3:natives-linux",
"org.lwjgl:lwjgl-openal:3.3.3:natives-macos",
"org.lwjgl:lwjgl-openal:3.3.3:natives-macos-arm64",
"org.lwjgl:lwjgl-openal:3.3.3:natives-windows",
"org.lwjgl:lwjgl-openal:3.3.3:natives-windows-arm64",
"org.lwjgl:lwjgl-openal:3.3.3:natives-windows-x86",
"org.lwjgl:lwjgl-opengl:3.3.3",
"org.lwjgl:lwjgl-opengl:3.3.3:natives-linux",
"org.lwjgl:lwjgl-opengl:3.3.3:natives-macos",
"org.lwjgl:lwjgl-opengl:3.3.3:natives-macos-arm64",
"org.lwjgl:lwjgl-opengl:3.3.3:natives-windows",
"org.lwjgl:lwjgl-opengl:3.3.3:natives-windows-arm64",
"org.lwjgl:lwjgl-opengl:3.3.3:natives-windows-x86",
"org.lwjgl:lwjgl-stb:3.3.3",
"org.lwjgl:lwjgl-stb:3.3.3:natives-linux",
"org.lwjgl:lwjgl-stb:3.3.3:natives-macos",
"org.lwjgl:lwjgl-stb:3.3.3:natives-macos-arm64",
"org.lwjgl:lwjgl-stb:3.3.3:natives-windows",
"org.lwjgl:lwjgl-stb:3.3.3:natives-windows-arm64",
"org.lwjgl:lwjgl-stb:3.3.3:natives-windows-x86",
"org.lwjgl:lwjgl-tinyfd:3.3.3",
"org.lwjgl:lwjgl-tinyfd:3.3.3:natives-linux",
"org.lwjgl:lwjgl-tinyfd:3.3.3:natives-macos",
"org.lwjgl:lwjgl-tinyfd:3.3.3:natives-macos-arm64",
"org.lwjgl:lwjgl-tinyfd:3.3.3:natives-windows",
"org.lwjgl:lwjgl-tinyfd:3.3.3:natives-windows-arm64",
"org.lwjgl:lwjgl-tinyfd:3.3.3:natives-windows-x86",
"org.lwjgl:lwjgl:3.3.3",
"org.lwjgl:lwjgl:3.3.3:natives-linux",
"org.lwjgl:lwjgl:3.3.3:natives-macos",
"org.lwjgl:lwjgl:3.3.3:natives-macos-arm64",
"org.lwjgl:lwjgl:3.3.3:natives-windows",
"org.lwjgl:lwjgl:3.3.3:natives-windows-arm64",
"org.lwjgl:lwjgl:3.3.3:natives-windows-x86",
"org.lz4:lz4-java:1.8.0",
"org.slf4j:slf4j-api:2.0.9"
]
}
}

View file

@ -0,0 +1,9 @@
{
"1.21.1": {
"47.3.1": {
"type": "installer",
"url": "https://maven.neoforged.net/releases/net/neoforged/neoforge/21.1.54/neoforge-21.1.54-installer.jar",
"md5": "md5-ucnga+57fSrZVDGMesAUpg=="
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="com.mojang.util">
<Appenders>
<Console name="SysOut" target="SYSTEM_OUT">
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
</Console>
<Queue name="ServerGuiConsole">
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n" />
</Queue>
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
<Policies>
<TimeBasedTriggeringPolicy />
<OnStartupTriggeringPolicy />
</Policies>
<DefaultRolloverStrategy max="1000"/>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<Root level="info">
<filters>
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
</filters>
<AppenderRef ref="SysOut"/>
<AppenderRef ref="File"/>
<AppenderRef ref="ServerGuiConsole"/>
</Root>
</Loggers>
</Configuration>

View file

@ -0,0 +1,23 @@
# based on https://github.com/Infinidoge/nix-minecraft/blob/master/pkgs/build-support/mkTextileServer.nix
{ callPackage
, lib
, writeShellScriptBin
, gameVersion
, jre_headless
, loaderVersion
, loaderDrv
, loader ? (callPackage loaderDrv { inherit loaderVersion gameVersion jre_headless; })
, extraJavaArgs ? ""
, extraMinecraftArgs ? ""
}:
(writeShellScriptBin "minecraft-server" ''
exec ${lib.getExe jre_headless} ${extraJavaArgs} $@ @${loader}/libraries/net/minecraftforge/forge/${gameVersion}-${loaderVersion}/unix_args.txt nogui ${extraMinecraftArgs}''
) // rec {
pname = "minecraft-server";
version = "${gameVersion}-forge-${loaderVersion}";
name = "${pname}-${version}";
passthru = {
inherit loader;
};
}

Binary file not shown.