fruitbasket/modules/minecraft/default.nix

53 lines
1.7 KiB
Nix
Raw Normal View History

2024-08-26 13:53:44 +02:00
{ pkgs, config, lib, ... }:
2024-07-22 13:26:53 +02:00
{
2024-08-26 13:53:44 +02:00
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"minecraft-server"
];
services.minecraft-servers = {
2024-07-22 13:26:53 +02:00
enable = true;
eula = true;
2024-08-26 13:53:44 +02:00
servers.ifsr = {
enable = true;
package = pkgs.fabricServers.fabric-1_21;
jvmOpts = "-Xmx8192M -Xms8192M";
};
2024-07-22 13:26:53 +02:00
};
2024-07-22 18:05:26 +02:00
services.bluemap = {
enable = true;
host = "map.mc.ifsr.de";
eula = true;
2024-07-22 18:09:36 +02:00
onCalendar = "hourly";
2024-08-26 13:53:44 +02:00
defaultWorld = "/srv/minecraft/ifsr/world";
2024-07-22 18:05:26 +02:00
};
services.nginx.virtualHosts."map.mc.ifsr.de".extraConfig = ''
allow 141.30.0.0/16;
allow 141.76.0.0/16;
2024-08-29 07:59:46 +02:00
allow 217.160.244.15/32; # jonas uptime kuma
2024-07-22 18:05:26 +02:00
deny all;
'';
2024-07-22 13:26:53 +02:00
networking.firewall = {
extraInputRules = ''
2024-08-29 07:59:46 +02:00
ip saddr { 141.30.0.0/16, 141.76.0.0/16, 217.160.244.15/32 } tcp dport 25565 accept comment "Allow minecraft access from TU network and jonas monitoring"
2024-07-22 13:26:53 +02:00
'';
};
2024-07-22 18:05:26 +02:00
users.users.minecraft = {
isNormalUser = true;
isSystemUser = lib.mkForce false;
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILkxTuzjS3EswMfj+wSKu9ciRyStvjDlDUXzkqEUGDaP rouven@thinkpad"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOhdjiPvtAo/ZV36RjBBPSlixzeP3VN6cqa4YAmM5uXM ff00005@ff00005-laptop" # malte
];
};
security.sudo.extraRules = [
{
users = [ "minecraft" ];
commands = [
2024-08-26 13:53:44 +02:00
{ command = "/run/current-system/sw/bin/systemctl restart minecraft-server-ifsr"; options = [ "NOPASSWD" ]; }
{ command = "/run/current-system/sw/bin/systemctl start minecraft-server-ifsr"; options = [ "NOPASSWD" ]; }
{ command = "/run/current-system/sw/bin/systemctl stop minecraft-server-ifsr"; options = [ "NOPASSWD" ]; }
2024-07-22 18:05:26 +02:00
];
}
];
2024-07-22 13:26:53 +02:00
}