nixos/system/services/minecraft.nix

44 lines
1.3 KiB
Nix
Raw Normal View History

2024-07-30 15:06:34 +01:00
{ config, pkgs, ... }:
{
nixpkgs.overlays = [
# Fetch papermc v1.21 from unstable branch of nixpkgs
2024-07-30 15:06:34 +01:00
(
final: prev:
let
pinnedPkgs = import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/03a94c776f261b78b95de0971a94dea0199b4cd8.tar.gz";
sha256 = "0vngf4g468qd5fqch85nzyvn7bpa6p2i6rdmzc6ws2653x868w3g";
}) { inherit (pkgs) system; };
in
{
inherit (pinnedPkgs) papermc papermcServers;
}
)
];
2024-02-09 14:08:42 +00:00
services.minecraft-server = {
enable = true;
package = pkgs.papermcServers.papermc-1_21;
2024-02-09 14:08:42 +00:00
eula = true;
openFirewall = true;
2024-02-09 14:08:42 +00:00
declarative = true;
jvmOpts = "-Xmx4G -Xms4G";
2024-02-09 14:08:42 +00:00
whitelist = {
"pixelifytica" = "b1848d60-4ddd-4fa4-a328-fb269910b6ae";
"HomeInTheClouds" = "d49f0aee-f217-477b-9516-9d5906f7fc87";
2024-02-09 14:08:42 +00:00
};
serverProperties = {
server-port = 25565;
difficulty = "easy";
2024-02-09 14:08:42 +00:00
gamemode = "survival";
force-gamemode = true;
max-players = 10;
# level-seed = 238902389203;
motd = "NixOS Minecraft server!";
white-list = true;
};
};
2024-02-22 14:11:13 +00:00
# Caddy forwarding
services.caddy.virtualHosts."craft.xenia.me.uk".extraConfig = "reverse_proxy http://localhost:${toString config.services.minecraft-server.serverProperties.server-port}";
2024-02-09 14:08:42 +00:00
}