nixos: add minecraft-server service
Signed-off-by: Austin Seipp <aseipp@pobox.com>
This commit is contained in:
parent
d60af7f34d
commit
1acca1c396
3 changed files with 53 additions and 0 deletions
|
@ -122,6 +122,7 @@
|
|||
notbit = 111;
|
||||
ngircd = 112;
|
||||
btsync = 113;
|
||||
minecraft = 114;
|
||||
|
||||
# When adding a uid, make sure it doesn't match an existing gid.
|
||||
|
||||
|
|
|
@ -96,6 +96,7 @@
|
|||
./services/databases/postgresql.nix
|
||||
./services/databases/virtuoso.nix
|
||||
./services/games/ghost-one.nix
|
||||
./services/games/minecraft-server.nix
|
||||
./services/hardware/acpid.nix
|
||||
./services/hardware/amd-hybrid-graphics.nix
|
||||
./services/hardware/bluetooth.nix
|
||||
|
|
51
nixos/modules/services/games/minecraft-server.nix
Normal file
51
nixos/modules/services/games/minecraft-server.nix
Normal file
|
@ -0,0 +1,51 @@
|
|||
{ config, pkgs, ... }:
|
||||
|
||||
with pkgs.lib;
|
||||
|
||||
let
|
||||
cfg = config.services.minecraft-server;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
services.minecraft-server = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
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>.
|
||||
'';
|
||||
};
|
||||
|
||||
jvmOpts = mkOption {
|
||||
type = types.str;
|
||||
default = "-Xmx2048M -Xms2048M";
|
||||
description = "JVM options for the Minecraft Service.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
users.extraUsers.minecraft = {
|
||||
description = "Minecraft Server Service user";
|
||||
home = "/var/lib/minecraft";
|
||||
createHome = true;
|
||||
uid = config.ids.uids.minecraft;
|
||||
};
|
||||
|
||||
systemd.services.minecraft-server = {
|
||||
description = "Minecraft Server Service";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
|
||||
serviceConfig.Restart = "always";
|
||||
serviceConfig.User = "minecraft";
|
||||
script = ''
|
||||
cd /var/lib/minecraft
|
||||
exec ${pkgs.minecraft-server}/bin/minecraft-server ${cfg.jvmOpts}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue