2021-11-13 01:52:04 +01:00
{ lib , pkgs , . . . }:
let
papermc = {
ram = 4 ; # In GB
version = " 1 . 1 7 . 1 " ;
build = 189 ;
sha256 = " 0 6 g 2 v s 8 z 7 k 9 b l 8 a s j g d z 9 h 8 f k d 9 3 x a m 2 l b r g m z g a m w j p 9 4 g v f v r n " ;
} ;
2021-11-15 00:18:26 +01:00
port = 25565 ;
2021-11-13 01:52:04 +01:00
rconPort = 25575 ;
in
{
# Remote administration
environment . systemPackages = [ pkgs . mcrcon ] ;
# Use papermc
nixpkgs . overlays = [
( self : super : {
minecraft-server = super . minecraft-server . overrideAttrs ( old : {
src = pkgs . fetchurl {
url = with papermc ;
" h t t p s : / / p a p e r m c . i o / a p i / v 2 / p r o j e c t s / p a p e r / v e r s i o n s / ${ version } / b u i l d s / ${ toString build } / d o w n l o a d s / p a p e r - ${ version } - ${ toString build } . j a r " ;
sha256 = papermc . sha256 ;
} ;
} ) ;
} )
] ;
services . minecraft-server = {
enable = true ;
eula = true ;
declarative = true ;
jvmOpts = with papermc ;
" - X m s ${ toString ram } G - X m x ${ toString ram } G - X X : + U s e G 1 G C - X X : + P a r a l l e l R e f P r o c E n a b l e d - X X : M a x G C P a u s e M i l l i s = 2 0 0 - X X : + U n l o c k E x p e r i m e n t a l V M O p t i o n s - X X : + D i s a b l e E x p l i c i t G C - X X : + A l w a y s P r e T o u c h - X X : G 1 N e w S i z e P e r c e n t = 3 0 - X X : G 1 M a x N e w S i z e P e r c e n t = 4 0 - X X : G 1 H e a p R e g i o n S i z e = 8 M - X X : G 1 R e s e r v e P e r c e n t = 2 0 - X X : G 1 H e a p W a s t e P e r c e n t = 5 - X X : G 1 M i x e d G C C o u n t T a r g e t = 4 - X X : I n i t i a t i n g H e a p O c c u p a n c y P e r c e n t = 1 5 - X X : G 1 M i x e d G C L i v e T h r e s h o l d P e r c e n t = 9 0 - X X : G 1 R S e t U p d a t i n g P a u s e T i m e P e r c e n t = 5 - X X : S u r v i v o r R a t i o = 3 2 - X X : + P e r f D i s a b l e S h a r e d M e m - X X : M a x T e n u r i n g T h r e s h o l d = 1 " ;
# To get the uuids: https://mcuuid.net/
whitelist = {
gabriel_dr_dl = " 5 3 f c e d 4 9 - d a 5 1 - 4 c 8 2 - b 1 d 0 - 3 7 1 6 8 0 2 9 d b 0 8 " ;
aimie_dodo = " d 1 0 b e 0 2 0 - a 6 1 2 - 4 7 e 5 - b 0 d 0 - 9 3 8 b 9 a 7 e b 5 8 e " ;
2021-11-15 00:19:27 +01:00
RaitoMezarius = " a 4 0 0 6 8 6 e - 0 f 6 2 - 4 3 d 5 - b 5 c 6 - 4 2 9 5 b a b c c 0 0 8 " ;
2021-11-13 01:52:04 +01:00
} ;
serverProperties = {
server-port = port ;
difficulty = " n o r m a l " ;
gamemode = " s u r v i v a l " ;
max-players = 42 ;
motd = " T h i s i s a t e s t a n d i t w i l l b r e a k " ;
view-distance = 7 ;
# Map settings
level-seed = " 9 0 5 8 1 3 6 6 3 0 9 4 4 9 5 6 7 5 5 " ;
2021-11-14 01:28:51 +01:00
level-name = " P u b l i c _ C O F " ;
2021-11-13 01:52:04 +01:00
level-type = " d e f a u l t " ;
spawn-animals = true ;
spawn-monsters = true ;
spawn-npcs = true ;
generate-structures = true ;
enable-command-block = false ;
# Whitelist
white-list = true ;
enforce-whitelist = true ;
# Admin
enable-rcon = true ;
" r c o n . p a s s w o r d " =
'' y Q Z > O . % ] f B { ' E . X = H I 1 / E n ~ i - '' ; # TODO Warning: it is written in clear in /var/lib/... with read permissions and mcrcom will transmit it without encryption
" r c o n . p o r t " = rconPort ;
admin-slot = true ;
snoop-enabled = false ;
public = false ;
# enable-jmx-monitoring = true; # https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html
} ;
} ;
networking . firewall . allowedTCPPorts = [ port ] ;
networking . firewall . allowedUDPPorts = [ port ] ;
}