From 2894eaf108f1b3d030062e3d88543f70e763fab9 Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Tue, 4 Feb 2025 10:20:57 +0100 Subject: [PATCH] defiant: Add 'home' minecraft server --- hosts/defiant/configuration.nix | 2 +- hosts/defiant/services/minecraft/home.nix | 49 +++++++++++++++++++ .../{minecraft.nix => minecraft/wack.nix} | 0 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 hosts/defiant/services/minecraft/home.nix rename hosts/defiant/services/{minecraft.nix => minecraft/wack.nix} (100%) diff --git a/hosts/defiant/configuration.nix b/hosts/defiant/configuration.nix index b5fe5fd..4ef4068 100644 --- a/hosts/defiant/configuration.nix +++ b/hosts/defiant/configuration.nix @@ -26,7 +26,7 @@ ./services/koillection.nix ./services/matrix ./services/microbin.nix - # ./services/minecraft.nix + ./services/minecraft/home.nix ./services/monitoring ./services/rtl-tcp.nix ./services/searx.nix diff --git a/hosts/defiant/services/minecraft/home.nix b/hosts/defiant/services/minecraft/home.nix new file mode 100644 index 0000000..fd47f53 --- /dev/null +++ b/hosts/defiant/services/minecraft/home.nix @@ -0,0 +1,49 @@ +{ config, pkgs, lib, inputs, ... }: +{ + imports = [ inputs.nix-minecraft.nixosModules.minecraft-servers ]; + nixpkgs.overlays = [ inputs.nix-minecraft.overlay ]; + + services.minecraft-servers = { + enable = true; + eula = true; + openFirewall = true; + dataDir = "/var/lib/minecraft-server"; + + servers.home = { + enable = true; + jvmOpts = "-Xms4G -Xmx4G"; + + package = pkgs.fabricServers.fabric-1_21_4; + + serverProperties = { + motd = "Home <3"; + difficulty = "easy"; + view-distance = 16; + simulation-distance = 16; + enable-command-block = true; + enable-rcon = true; + "rcon.password" = "wack"; + }; + + symlinks = { + mods = pkgs.linkFarmFromDrvs "mods" (builtins.attrValues { + FabricAPI = pkgs.fetchurl { + url = "https://cdn.modrinth.com/data/P7dR8mSH/versions/8FAH9fuR/fabric-api-0.114.2%2B1.21.4.jar"; + sha256 = "sha256-nL1bcAaMW0tRCpfW0prd3mce14ZNcl7pAUabVXAQfWs="; + }; + Lithium = pkgs.fetchurl { + url = "https://cdn.modrinth.com/data/gvQqBUqZ/versions/zVOQw7YU/lithium-fabric-0.14.6%2Bmc1.21.4.jar"; + sha256 = "sha256-iF4hy+3XVJP7Fv6R2dsrYq6Ct0MQJLX4/4Yh5WEJm90="; + }; + }); + }; + }; + }; + + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + "minecraft-server" + ]; + + networking.firewall.allowedUDPPorts = [ 24454 ]; +} + diff --git a/hosts/defiant/services/minecraft.nix b/hosts/defiant/services/minecraft/wack.nix similarity index 100% rename from hosts/defiant/services/minecraft.nix rename to hosts/defiant/services/minecraft/wack.nix