1
0

Compare commits

..

No commits in common. "097ea51d2df679080032019276b6b4a2fe4bb379" and "7a23f36b7de63355726af3ebbbca886e8df6f346" have entirely different histories.

3 changed files with 9 additions and 89 deletions

View File

@ -28,11 +28,16 @@ in {
networking.defaultGateway6 = { address = "2001:638:904:ffcb::1"; interface = "ens18"; }; networking.defaultGateway6 = { address = "2001:638:904:ffcb::1"; interface = "ens18"; };
networking.nameservers = [ "2001:638:904:ffcc::3" "2001:638:904:ffcc::4" "141.24.40.3" "141.24.40.4" ]; networking.nameservers = [ "2001:638:904:ffcc::3" "2001:638:904:ffcc::4" "141.24.40.3" "141.24.40.4" ];
clerie.minecraft-server.servers.aerilon.enable = true; # port 25565 services.minecraft-server = {
clerie.minecraft-server.servers.riese.enable = true; # port 25566 enable = true;
clerie.minecraft-server.servers.chaos.enable = true; # port 25568 eula = true;
dataDir = "/var/lib/minecraft-server";
package = pkgs.papermc;
jvmOpts = "-Xmx4G -Xms1G";
};
networking.firewall.allowedTCPPorts = [ 25565 25566 25568 ]; networking.firewall.allowedUDPPorts = [ 25565 ];
networking.firewall.allowedTCPPorts = [ 25565 ];
system.stateVersion = "21.03"; system.stateVersion = "21.03";
} }

View File

@ -6,7 +6,6 @@
./anycast_healthchecker ./anycast_healthchecker
./gitea ./gitea
./gre-tunnel ./gre-tunnel
./minecraft-server
./nginx-port-forward ./nginx-port-forward
]; ];
} }

View File

@ -1,84 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.clerie.minecraft-server;
# We don't allow eula=false anyways
eulaFile = builtins.toFile "eula.txt" ''
# eula.txt managed by NixOS Configuration
eula=true
'';
generateServerUnit = name: server: (
nameValuePair "minecraft-server-${name}" (mkIf server.enable {
description = "Minecraft Server ${name}";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
ExecStart = "${server.package}/bin/minecraft-server ${server.jvmOpts}";
Restart = "always";
WorkingDirectory = if server.dataDir != null then server.dataDir else "/var/lib/minecraft-server-${name}";
StateDirectory = "minecraft-server-${name}";
DynamicUser = true;
};
preStart = ''
ln -sf ${eulaFile} eula.txt
'';
})
);
serverOpts = { config, ... }@moduleAttrs: {
options = {
enable = mkEnableOption "A shared minecraft hosting service.";
dataDir = mkOption {
type = with types; nullOr path;
default = null;
description = ''
Directory to store Minecraft database and other state/data files.
When null defaulting to /var/lib/minecraft-server-${name}
'';
};
package = mkOption {
type = types.package;
default = pkgs.papermc;
defaultText = "pkgs.papermc";
example = literalExample "pkgs.minecraft-server_1_12_2";
description = "Version of minecraft-server to run.";
};
jvmOpts = mkOption {
type = types.separatedString " ";
default = "-Xmx2G -Xms1G";
# Example options from https://minecraft.gamepedia.com/Tutorials/Server_startup_script
example = "-Xmx2048M -Xms4092M -XX:+UseG1GC -XX:+CMSIncrementalPacing "
+ "-XX:+CMSClassUnloadingEnabled -XX:ParallelGCThreads=2 "
+ "-XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10";
description = "JVM options for the Minecraft server.";
};
};
};
in {
options = {
clerie.minecraft-server = {
servers = mkOption {
type = with types; attrsOf (submodule serverOpts);
default = {};
};
};
};
config = {
systemd.services = (mapAttrs' generateServerUnit cfg.servers);
};
}