Merge pull request #15403 from Shados/maintain-teamspeak-server

teamspeak-server package & module maintenance
This commit is contained in:
Joachim Fasting 2016-05-12 13:01:38 +02:00
commit 639dcffa0b
2 changed files with 39 additions and 36 deletions

View File

@ -10,13 +10,12 @@ let
in in
{ {
###### interface ###### interface
options = { options = {
services.teamspeak3 = { services.teamspeak3 = {
enable = mkOption { enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
@ -96,34 +95,32 @@ in
###### implementation ###### implementation
config = mkIf cfg.enable { config = mkMerge [
(mkIf cfg.enable {
users.extraUsers.teamspeak = users.users.teamspeak = {
{ name = "teamspeak";
description = "Teamspeak3 voice communication server daemon"; description = "Teamspeak3 voice communication server daemon";
group = group; group = group;
uid = config.ids.uids.teamspeak; uid = config.ids.uids.teamspeak;
home = cfg.dataDir;
createHome = true;
}; };
users.extraGroups.teamspeak = users.groups.teamspeak = {
{ name = "teamspeak";
gid = config.ids.gids.teamspeak; gid = config.ids.gids.teamspeak;
}; };
systemd.services.teamspeak3-server = { systemd.services.teamspeak3-server = {
description = "Teamspeak3 voice communication server daemon"; description = "Teamspeak3 voice communication server daemon";
after = [ "network.target" ]; after = [ "network.target" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
preStart = '' preStart = ''
mkdir -p ${cfg.dataDir} mkdir -p ${cfg.logPath}
mkdir -p ${cfg.logPath} chown ${user}:${group} ${cfg.logPath}
chown ${user}:${group} ${cfg.dataDir} '';
chown ${user}:${group} ${cfg.logPath}
'';
serviceConfig = serviceConfig = {
{ ExecStart = '' ExecStart = ''
${ts3}/bin/ts3server \ ${ts3}/bin/ts3server \
dbsqlpath=${ts3}/lib/teamspeak/sql/ logpath=${cfg.logPath} \ dbsqlpath=${ts3}/lib/teamspeak/sql/ logpath=${cfg.logPath} \
voice_ip=${cfg.voiceIP} default_voice_port=${toString cfg.defaultVoicePort} \ voice_ip=${cfg.voiceIP} default_voice_port=${toString cfg.defaultVoicePort} \
@ -133,10 +130,12 @@ in
WorkingDirectory = cfg.dataDir; WorkingDirectory = cfg.dataDir;
User = user; User = user;
Group = group; Group = group;
PermissionsStartOnly = true; # preStart needs to run with root permissions PermissionsStartOnly = true;
}; };
}; };
})
}; {
meta.maintainers = with lib.maintainers; [ arobyn ];
}
];
} }

View File

@ -1,11 +1,8 @@
{ stdenv, fetchurl, makeWrapper }: { stdenv, fetchurl, makeWrapper }:
let let
version = "3.0.12.4";
version = "3.0.10.3";
arch = if stdenv.is64bit then "amd64" else "x86"; arch = if stdenv.is64bit then "amd64" else "x86";
libDir = if stdenv.is64bit then "lib64" else "lib"; libDir = if stdenv.is64bit then "lib64" else "lib";
in in
@ -14,25 +11,30 @@ stdenv.mkDerivation {
src = fetchurl { src = fetchurl {
urls = [ urls = [
"http://dl.4players.de/ts/releases/${version}/teamspeak3-server_linux-${arch}-${version}.tar.gz" "http://dl.4players.de/ts/releases/${version}/teamspeak3-server_linux_${arch}-${version}.tar.bz2"
"http://teamspeak.gameserver.gamed.de/ts3/releases/${version}/teamspeak3-server_linux-${arch}-${version}.tar.gz" "http://teamspeak.gameserver.gamed.de/ts3/releases/${version}/teamspeak3-server_linux_${arch}-${version}.tar.bz2"
]; ];
sha256 = if stdenv.is64bit sha256 = if stdenv.is64bit
then "9606dd5c0c3677881b1aab833cb99f4f12ba08cc77ef4a97e9e282d9e10b0702" then "1n8vgbgnfbllfvsl82ai6smv6hl32a3nd071j2dp79agjz4fic3b"
else "8b8921e0df04bf74068a51ae06d744f25d759a8c267864ceaf7633eb3f81dbe5"; else "19vkcgb0h71amixry8r72qqwaxwplzyz9nrxg5bdjjg8r2mkh4bc";
}; };
buildInputs = [ makeWrapper ]; buildInputs = [ makeWrapper ];
buildPhase = buildPhase =
'' ''
mv ts3server_linux_${arch} ts3server
echo "patching ts3server" echo "patching ts3server"
patchelf \ patchelf \
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $(cat $NIX_CC/nix-support/orig-cc)/${libDir} \ --set-rpath $(cat $NIX_CC/nix-support/orig-cc)/${libDir} \
--force-rpath \ --force-rpath \
ts3server ts3server
cp tsdns/tsdnsserver tsdnsserver
patchelf \
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $(cat $NIX_CC/nix-support/orig-cc)/${libDir} \
--force-rpath \
tsdnsserver
''; '';
installPhase = installPhase =
@ -44,17 +46,19 @@ stdenv.mkDerivation {
mkdir -p $out/lib/teamspeak mkdir -p $out/lib/teamspeak
mv * $out/lib/teamspeak/ mv * $out/lib/teamspeak/
# Make a symlink to the binary from bin. # Make symlinks to the binaries from bin.
mkdir -p $out/bin/ mkdir -p $out/bin/
ln -s $out/lib/teamspeak/ts3server $out/bin/ts3server ln -s $out/lib/teamspeak/ts3server $out/bin/ts3server
ln -s $out/lib/teamspeak/tsdnsserver $out/bin/tsdnsserver
wrapProgram $out/lib/teamspeak/ts3server --prefix LD_LIBRARY_PATH : $out/lib/teamspeak wrapProgram $out/lib/teamspeak/ts3server --prefix LD_LIBRARY_PATH : $out/lib/teamspeak
wrapProgram $out/lib/teamspeak/tsdnsserver --prefix LD_LIBRARY_PATH : $out/lib/tsdnsserver
''; '';
dontStrip = true; dontStrip = true;
dontPatchELF = true; dontPatchELF = true;
meta = { meta = {
description = "TeamSpeak voice communication server"; description = "TeamSpeak voice communication server";
homepage = http://teamspeak.com/; homepage = http://teamspeak.com/;
license = stdenv.lib.licenses.unfreeRedistributable; license = stdenv.lib.licenses.unfreeRedistributable;