chore: update server + refactor

This commit is contained in:
♥ Minnie ♥ 2025-06-13 20:39:36 +08:00
parent 23d1a07f26
commit f4ac9c1753
Signed by: jasmine
GPG key ID: 8563E358D4E8040E
2 changed files with 31 additions and 25 deletions

6
flake.lock generated
View file

@ -494,11 +494,11 @@
"nixpkgs": "nixpkgs_3" "nixpkgs": "nixpkgs_3"
}, },
"locked": { "locked": {
"lastModified": 1749175420, "lastModified": 1749780394,
"narHash": "sha256-5gOh2Jpp7HLzyV3RVkIS88F9lhpnTpsCzOu8J1w7Uuo=", "narHash": "sha256-KZypZIU6L2EJRej+nBm5IuW6Q8nfccvylXWMkfhHTCA=",
"owner": "Infinidoge", "owner": "Infinidoge",
"repo": "nix-minecraft", "repo": "nix-minecraft",
"rev": "ad263175ac965617a3fe4b3d46e1fcabb4964f51", "rev": "4f330afee93356ceedf61c772f9a296388db76aa",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -6,9 +6,9 @@
... ...
}: let }: let
modpack = pkgs.fetchPackwizModpack rec { modpack = pkgs.fetchPackwizModpack rec {
version = "7091175"; version = "4d507be";
url = "https://raw.githubusercontent.com/sajenim/minecraft-modpack/${version}/pack.toml"; url = "https://raw.githubusercontent.com/sajenim/minecraft-modpack/${version}/pack.toml";
packHash = "sha256-9HZipG6/8GKnbXp0Qfug8Y2Db96hageUtprAuuuuGPM="; packHash = "sha256-1Za6ZSLVE6jbwlqkJriQNvuoFAnOVz76t8BWtR6al7o=";
}; };
mcVersion = modpack.manifest.versions.minecraft; mcVersion = modpack.manifest.versions.minecraft;
fabricVersion = modpack.manifest.versions.fabric; fabricVersion = modpack.manifest.versions.fabric;
@ -46,7 +46,7 @@ in {
serverProperties = { serverProperties = {
gamemode = "survival"; gamemode = "survival";
difficulty = "normal"; difficulty = "normal";
motd = "\\u00A7aKanto Network \\u00A7e[1.19.2]\\u00A7r\\n\\u00A78I'll Use My Trusty Frying Pan As A Drying Pan!"; motd = "\\u00A7aKanto Network \\u00A7e[1.20.1]\\u00A7r\\n\\u00A78I'll Use My Trusty Frying Pan As A Drying Pan!";
server-port = 25565; server-port = 25565;
white-list = true; white-list = true;
spawn-protection = 0; spawn-protection = 0;
@ -61,9 +61,6 @@ in {
# Things to copy into this server's data directory. # Things to copy into this server's data directory.
files = { files = {
"ops.json" = ./ops.json; "ops.json" = ./ops.json;
# Youre in grave danger
"config/yigd.toml" = "${modpack}/config/yigd.toml";
}; };
# Value of systemd's `Restart=` service configuration option. # Value of systemd's `Restart=` service configuration option.
@ -76,27 +73,35 @@ in {
# Open firewall for all servers. # Open firewall for all servers.
openFirewall = true; openFirewall = true;
# Enable systemd socket activation.
managementSystem.systemd-socket.enable = true;
# https://account.mojang.com/documents/minecraft_eula # Accept the minecraft EULA.
eula = true; eula = true;
# https://account.mojang.com/documents/minecraft_eula
}; };
services.traefik.dynamicConfigOptions.http.routers = { # Enable the Traefik reverse proxy.
minecraft = { services.traefik.dynamicConfigOptions.http = {
rule = "Host(`mc.home.arpa`)"; # Enable the Traefik HTTP router for the minecraft server.
entryPoints = [ routers = {
"websecure" minecraft = {
]; rule = "Host(`mc.home.arpa`)";
service = "minecraft"; entryPoints = [
"websecure"
];
service = "minecraft";
};
};
# Define the service for the minecraft server.
services = {
minecraft.loadBalancer.servers = [
{url = "http://127.0.0.1:${toString config.services.minecraft-servers.servers.kanto.serverProperties.server-port}";}
];
}; };
};
services.traefik.dynamicConfigOptions.http.services = {
minecraft.loadBalancer.servers = [
{url = "http://127.0.0.1:${toString config.services.minecraft-servers.servers.kanto.serverProperties.server-port}";}
];
};
# Enable persistence for the data directory.
environment.persistence."/persist" = { environment.persistence."/persist" = {
directories = [ directories = [
{ {
@ -106,7 +111,8 @@ in {
} }
]; ];
}; };
# Allow unfree packages.
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"minecraft-server" "minecraft-server"
]; ];