diff options
author | Azat Bahawi <azat@bahawi.net> | 2023-01-30 01:48:52 +0300 |
---|---|---|
committer | Azat Bahawi <azat@bahawi.net> | 2023-01-30 01:48:52 +0300 |
commit | e8dbb049452e014fe89df34cb8f29e7c21c37666 (patch) | |
tree | 8102c252877057fc5c1d5914b36cbb167927e153 /modules/nixos/games/minecraft.nix | |
parent | 2023-01-05 (diff) |
2023-01-30
Diffstat (limited to '')
-rw-r--r-- | modules/nixos/games/minecraft.nix | 64 |
1 files changed, 50 insertions, 14 deletions
diff --git a/modules/nixos/games/minecraft.nix b/modules/nixos/games/minecraft.nix index 7b21195..09b9239 100644 --- a/modules/nixos/games/minecraft.nix +++ b/modules/nixos/games/minecraft.nix @@ -1,5 +1,6 @@ { config, + inputs, lib, pkgs, ... @@ -7,11 +8,19 @@ with lib; let cfg = config.nixfiles.modules.games.minecraft; in { + imports = [inputs.nix-minecraft.nixosModules.minecraft-servers]; + options.nixfiles.modules.games.minecraft = { client.enable = mkEnableOption "Minecraft client"; server = { enable = mkEnableOption "Minecraft server"; + port = mkOption { + description = "OpenSSH server port."; + type = types.port; + default = 50505; # Keeping 25565 as the default is a big security risk. + }; + memory = mkOption { description = "Amount of RAM to allocate."; type = types.str; @@ -25,26 +34,53 @@ in { hm.home.packages = with pkgs; [prismlauncher]; }) (mkIf cfg.server.enable { - # Configurations, opslist, whitelist and plugins are managed imperatively. - # TODO Make it declarative. - services.minecraft-server = { + nixfiles.modules.common.nix.allowedUnfreePackages = ["minecraft-server"]; + + ark.directories = [config.services.minecraft-servers.dataDir]; + + services.minecraft-servers = { enable = true; eula = true; - package = pkgs.minecraftServers.purpur_1_19_3; + openFirewall = true; + + servers.default = { + enable = true; + autoStart = true; + + package = pkgs.paperServers.paper-1_19_3; + + serverProperties = { + # motd = ""; + # white-list = true; + allow-flight = true; + difficulty = "hard"; + enable-command-block = true; + enforce-secure-profile = false; + enforce-whitelist = true; + gamemode = "survival"; + level-name = "default"; + max-players = 8; + online-mode = false; + previews-chat = false; + pvp = false; + server-port = cfg.server.port; + snooper-enabled = false; + }; + + whitelist = {}; # TODO Fill this. - # TODO Make a PR fixing trailing whitespace on this. - jvmOpts = - (concatStringsSep " " [ - "-Xmx${cfg.server.memory}" - "-Xms${cfg.server.memory}" - "--add-modules=jdk.incubator.vector" - ]) - + " "; + jvmOpts = + (concatStringsSep " " [ + "-Xms${cfg.server.memory}" + "-Xmx${cfg.server.memory}" + "--add-modules=jdk.incubator.vector" # Required by some plugins. + ]) + + " "; + }; }; - # Defined in /var/lib/minecraft/server.properties. - networking.firewall.allowedTCPPorts = [55565]; + my.extraGroups = [config.services.minecraft-servers.group]; }) ]; } |