From 25c595f32e44fb088b985d3c30b9911787413cfc Mon Sep 17 00:00:00 2001 From: NullBite Date: Sun, 24 Mar 2024 10:38:31 -0400 Subject: [PATCH] Configure Minecraft server options The server configuration is currently disabled due to Infinidoge/nix-minecraft#60 --- hosts/nullbox/hardware-configuration.nix | 6 ++ hosts/nullbox/mcserver.nix | 73 +++++++++++++++++++++++- 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/hosts/nullbox/hardware-configuration.nix b/hosts/nullbox/hardware-configuration.nix index 57c90b6..bca77aa 100644 --- a/hosts/nullbox/hardware-configuration.nix +++ b/hosts/nullbox/hardware-configuration.nix @@ -47,6 +47,12 @@ options = [ "subvol=@mcserver" ]; }; + fileSystems."/srv/mcserver/.snapshots" = + { device = "/dev/disk/by-uuid/7204ff85-6404-4bd7-ba0d-3fb23a5cf52c"; + fsType = "btrfs"; + options = [ "subvol=snapshots/@mcserver" ]; + }; + swapDevices = [ ]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking diff --git a/hosts/nullbox/mcserver.nix b/hosts/nullbox/mcserver.nix index 33c1fe7..d50fe9e 100644 --- a/hosts/nullbox/mcserver.nix +++ b/hosts/nullbox/mcserver.nix @@ -1,7 +1,78 @@ { pkgs, lib, config, ... }: +let + cfg = config.services.minecraft-servers; +in { config = { - fileSystems."/srv/mcserver".options = [ "compress=zstd" "nofail" ]; + fileSystems = { + "/srv/mcserver".options = [ "compress=zstd" "nofail" ]; + "/srv/mcserver/.snapshots".options = [ "compress=zstd" "nofail" ]; + }; networking.firewall.trustedInterfaces = [ "wg0" ]; + + users = { + users = { + nullbite.extraGroups = [ "minecraft" ]; + }; + }; + + services.snapper = { + configs.mcserver = { + FSTYPE = "btrfs"; + SUBVOLUME = "/srv/mcserver"; + TIMELINE_CREATE = true; + TIMELINE_CLEANUP = true; + TIMELINE_MIN_AGE = 1800; + TIMELINE_LIMIT_HOURLY = 36; + TIMELINE_LIMIT_DAILY = 14; + TIMELINE_LIMIT_WEEKLY = 4; + TIMELINE_LIMIT_MONTHLY = 12; + TIMELINE_LIMIT_YEARLY = 10000; + }; + }; + + services.minecraft-servers = { + enable = true; + eula = true; + dataDir = "/srv/mcserver"; + servers = { + minecraft-nixtest = let + self = cfg.servers.minecraft-nixtest; + package = pkgs.quiltServers.quilt-1_20_1.override { loaderVersion = "0.21.0"; }; + modpack = pkgs.fetchPackwizModpack { + url = "https://gitea.protogen.io/nullbite/notlite/raw/branch/release/1.20.1/pack.toml"; + packHash = "sha256-N3Pdlqte8OYz6wz3O/TSG75FMAV+XWAipqoXsYbcYDQ="; + }; + in { + enable = false; + inherit package; + autoStart = self.enable; + whitelist = { + YzumThreeEye = "3dad78e8-6979-404f-820e-952ce20964a0"; + NullBite = "e24e8e0e-7540-4126-b737-90043155bcd4"; + Silveere = "468554f1-27cd-4ea1-9308-3dd14a9b1a12"; + }; + symlinks = let + symlinkFolders = lib.genAttrs [ "mods" "kubejs" ] (x: "${modpack}/${x}"); + in symlinkFolders; + serverProperties = { + # allow NCR + enforce-secure-profile = false; + white-list = true; + enforce-whitelist = true; + + motd = "owo what's this (nix edition)"; + + enable-rcon = false; + difficulty = "hard"; + hardcore = false; + online-mode = true; + pvp = true; + + sync-chunk-writes = false; + }; + }; + }; + }; }; }