mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-15 13:37:21 +03:00
Merge pull request #7239 from cwoac/minecraft
allow changing minecraft data dir + allow opening firewall
This commit is contained in:
commit
4ebc94db5b
@ -8,6 +8,7 @@ in
|
||||
{
|
||||
options = {
|
||||
services.minecraft-server = {
|
||||
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
@ -15,7 +16,23 @@ in
|
||||
If enabled, start a Minecraft Server. The listening port for
|
||||
the server is always <literal>25565</literal>. The server
|
||||
data will be loaded from and saved to
|
||||
<literal>/var/lib/minecraft</literal>.
|
||||
<literal>${cfg.dataDir}</literal>.
|
||||
'';
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/lib/minecraft";
|
||||
description = ''
|
||||
Directory to store minecraft database and other state/data files.
|
||||
'';
|
||||
};
|
||||
|
||||
openFirewall = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to open ports in the firewall (if enabled) for the server.
|
||||
'';
|
||||
};
|
||||
|
||||
@ -30,7 +47,7 @@ in
|
||||
config = mkIf cfg.enable {
|
||||
users.extraUsers.minecraft = {
|
||||
description = "Minecraft Server Service user";
|
||||
home = "/var/lib/minecraft";
|
||||
home = cfg.dataDir;
|
||||
createHome = true;
|
||||
uid = config.ids.uids.minecraft;
|
||||
};
|
||||
@ -43,9 +60,14 @@ in
|
||||
serviceConfig.Restart = "always";
|
||||
serviceConfig.User = "minecraft";
|
||||
script = ''
|
||||
cd /var/lib/minecraft
|
||||
cd ${cfg.dataDir}
|
||||
exec ${pkgs.minecraft-server}/bin/minecraft-server ${cfg.jvmOpts}
|
||||
'';
|
||||
};
|
||||
|
||||
networking.firewall = mkIf cfg.openFirewall {
|
||||
allowedUDPPorts = [ 25565 ];
|
||||
allowedTCPPorts = [ 25565 ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user