diff --git a/lib/maintainers.nix b/lib/maintainers.nix index 80d0bed23dc..109e7956a58 100644 --- a/lib/maintainers.nix +++ b/lib/maintainers.nix @@ -14,6 +14,7 @@ AndersonTorres = "Anderson Torres "; andres = "Andres Loeh "; antono = "Antono Vasiljev "; + arobyn = "Alexei Robyn "; astsmtl = "Alexander Tsamutali "; aszlig = "aszlig "; bbenoist = "Baptist BENOIST "; diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index 207da2a39bf..13ec502047d 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -131,6 +131,7 @@ starbound = 120; hydra = 122; spiped = 123; + teamspeak = 124; # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! @@ -236,6 +237,7 @@ grsecurity = 121; hydra = 122; spiped = 123; + teamspeak = 124; # When adding a gid, make sure it doesn't match an existing uid. And don't use gids above 399! diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index def4d10f366..0737da71923 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -222,6 +222,7 @@ ./services/networking/syncthing.nix ./services/networking/ssh/lshd.nix ./services/networking/ssh/sshd.nix + ./services/networking/teamspeak3.nix ./services/networking/tftpd.nix ./services/networking/unbound.nix ./services/networking/vsftpd.nix diff --git a/nixos/modules/services/networking/teamspeak3.nix b/nixos/modules/services/networking/teamspeak3.nix new file mode 100644 index 00000000000..2d3478d52f8 --- /dev/null +++ b/nixos/modules/services/networking/teamspeak3.nix @@ -0,0 +1,142 @@ +{ config, pkgs, ... }: + +with pkgs.lib; + +let + ts3 = pkgs.teamspeak_server; + cfg = config.services.teamspeak3; + user = "teamspeak"; + group = "teamspeak"; +in + +{ + + ###### interface + + options = { + + services.teamspeak3 = { + + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to run the Teamspeak3 voice communication server daemon. + ''; + }; + + dataDir = mkOption { + type = types.path; + default = "/var/lib/teamspeak3-server"; + description = '' + Directory to store TS3 database and other state/data files. + ''; + }; + + logPath = mkOption { + type = types.path; + default = "/var/log/teamspeak3-server/"; + description = '' + Directory to store log files in. + ''; + }; + + voiceIP = mkOption { + type = types.str; + default = "0.0.0.0"; + description = '' + IP on which the server instance will listen for incoming voice connections. Defaults to any IP. + ''; + }; + + defaultVoicePort = mkOption { + type = types.int; + default = 9987; + description = '' + Default UDP port for clients to connect to virtual servers - used for first virtual server, subsequent ones will open on incrementing port numbers by default. + ''; + }; + + fileTransferIP = mkOption { + type = types.str; + default = "0.0.0.0"; + description = '' + IP on which the server instance will listen for incoming file transfer connections. Defaults to any IP. + ''; + }; + + fileTransferPort = mkOption { + type = types.int; + default = 30033; + description = '' + TCP port opened for file transfers. + ''; + }; + + queryIP = mkOption { + type = types.str; + default = "0.0.0.0"; + description = '' + IP on which the server instance will listen for incoming ServerQuery connections. Defaults to any IP. + ''; + }; + + queryPort = mkOption { + type = types.int; + default = 10011; + description = '' + TCP port opened for ServerQuery connections. + ''; + }; + + }; + + }; + + + ###### implementation + + config = mkIf cfg.enable { + + users.extraUsers.teamspeak = + { name = "teamspeak"; + description = "Teamspeak3 voice communication server daemon"; + group = group; + uid = config.ids.uids.teamspeak; + }; + + users.extraGroups.teamspeak = + { name = "teamspeak"; + gid = config.ids.gids.teamspeak; + }; + + systemd.services.teamspeak3-server = { + description = "Teamspeak3 voice communication server daemon"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + + preStart = '' + mkdir -p ${cfg.dataDir} + mkdir -p ${cfg.logPath} + chown ${user}:${group} ${cfg.dataDir} + chown ${user}:${group} ${cfg.logPath} + ''; + + serviceConfig = + { ExecStart = '' + ${ts3}/bin/ts3server \ + dbsqlpath=${ts3}/lib/teamspeak/sql/ logpath=${cfg.logPath} \ + voice_ip=${cfg.voiceIP} default_voice_port=${toString cfg.defaultVoicePort} \ + filetransfer_ip=${cfg.fileTransferIP} filetransfer_port=${toString cfg.fileTransferPort} \ + query_ip=${cfg.queryIP} query_port=${toString cfg.queryPort} + ''; + WorkingDirectory = cfg.dataDir; + User = user; + Group = group; + PermissionsStartOnly = true; # preStart needs to run with root permissions + }; + }; + + }; + +} diff --git a/pkgs/applications/networking/instant-messengers/teamspeak/server.nix b/pkgs/applications/networking/instant-messengers/teamspeak/server.nix new file mode 100644 index 00000000000..7a57cb8ad62 --- /dev/null +++ b/pkgs/applications/networking/instant-messengers/teamspeak/server.nix @@ -0,0 +1,99 @@ +{ stdenv, fetchurl, makeWrapper }: + +let + + version = "3.0.10.3"; + + arch = if stdenv.is64bit then "amd64" else "x86"; + + libDir = if stdenv.is64bit then "lib64" else "lib"; +in + +stdenv.mkDerivation { + name = "teamspeak-server-${version}"; + + src = fetchurl { + urls = [ + "http://dl.4players.de/ts/releases/${version}/teamspeak3-server_linux-${arch}-${version}.tar.gz" + "http://teamspeak.gameserver.gamed.de/ts3/releases/${version}/teamspeak3-server_linux-${arch}-${version}.tar.gz" + ]; + sha256 = if stdenv.is64bit + then "9606dd5c0c3677881b1aab833cb99f4f12ba08cc77ef4a97e9e282d9e10b0702" + else "8b8921e0df04bf74068a51ae06d744f25d759a8c267864ceaf7633eb3f81dbe5"; + }; + + buildInputs = [ makeWrapper ]; + + buildPhase = + '' + mv ts3server_linux_${arch} ts3server + echo "patching ts3server" + patchelf \ + --interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" \ + --set-rpath $(cat $NIX_GCC/nix-support/orig-gcc)/${libDir} \ + --force-rpath \ + ts3server + ''; + + installPhase = + '' + # Delete unecessary libraries - these are provided by nixos. + #rm *.so* + + # Install files. + mkdir -p $out/lib/teamspeak + mv * $out/lib/teamspeak/ + + # Make a symlink to the binary from bin. + mkdir -p $out/bin/ + ln -s $out/lib/teamspeak/ts3server $out/bin/ts3server + + wrapProgram $out/lib/teamspeak/ts3server --prefix LD_LIBRARY_PATH : $out/lib/teamspeak + ''; + + dontStrip = true; + dontPatchELF = true; + + meta = { + description = "TeamSpeak voice communication server"; + homepage = http://teamspeak.com/; + license = stdenv.lib.licenses.unfreeRedistributable; + platforms = stdenv.lib.platforms.linux; + maintainers = [ stdenv.lib.maintainers.arobyn ]; + }; +} + +/* +License issues: +Date: Mon, 10 Dec 2007 19:55:16 -0500 +From: TeamSpeak Sales +To: 'Marc Weber' +Subject: RE: teamspeak on nix? + +Yes, that would be fine. As long as you are not renting servers or selling +TeamSpeak then you are more than welcome to distribute it. + +Thank you, + +TeamSpeak Sales Team +________________________________ +e-Mail: sales@tritoncia.com +TeamSpeak: http://www.TeamSpeak.com +Account Login: https://sales.TritonCIA.com/users + + + +-----Original Message----- +From: Marc Weber [mailto:marco-oweber@gmx.de] +Sent: Monday, December 10, 2007 5:03 PM +To: sales@tritoncia.com +Subject: teamspeak on nix? + +Hello, + +nix is very young software distribution system (http://nix.cs.uu.nl/) +I'd like to ask wether you permit us to add teamspeak (server/ client?) + +Sincerly +Marc Weber (small nix contributor) +*/ diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 45afaec8e34..d1c66f42a87 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9421,6 +9421,7 @@ let }; teamspeak_client = callPackage ../applications/networking/instant-messengers/teamspeak/client.nix { }; + teamspeak_server = callPackage ../applications/networking/instant-messengers/teamspeak/server.nix { }; taskjuggler = callPackage ../applications/misc/taskjuggler { };