Merge branch 'minecraft-server' of git://github.com/thoughtpolice/nixpkgs

nixpkgs: add Minecraft Server & a service module
This commit is contained in:
Shea Levy 2014-03-29 12:51:49 -04:00
commit ac68dc6dc6
5 changed files with 90 additions and 0 deletions

View File

@ -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.

View File

@ -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

View 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}
'';
};
};
}

View File

@ -0,0 +1,35 @@
{ stdenv, fetchurl, jre }:
with import <nixpkgs> {};
stdenv.mkDerivation rec {
name = "minecraft-server-${version}";
version = "1.7.5";
src = fetchurl {
url = "http://s3.amazonaws.com/Minecraft.Download/versions/${version}/minecraft_server.${version}.jar";
sha256 = "0f3sh3fws02yl4xqa8qrvn0cchfp0hymqrf30c5syzzcz9w4l8pq";
};
installPhase = ''
mkdir -p $out/bin $out/lib/minecraft
cp -v $src $out/lib/minecraft/server.jar
cat > $out/bin/minecraft-server << EOF
#!/bin/sh
exec ${jre}/bin/java \$@ -jar $out/lib/minecraft/server.jar nogui
EOF
chmod +x $out/bin/minecraft-server
'';
phases = "installPhase";
meta = {
description = "Minecraft Server";
homepage = "https://minecraft.net";
license = stdenv.lib.licenses.unfreeRedistributable;
platforms = stdenv.lib.platforms.unix;
maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
};
}

View File

@ -1394,6 +1394,8 @@ let
minecraft = callPackage ../games/minecraft { };
minecraft-server = callPackage ../games/minecraft-server { };
minetest = callPackage ../games/minetest {
libpng = libpng12;
};