Add TeamSpeak 3 server & service module (close #2056)

Conflicts (trivial):
lib/maintainers.nix
nixos/modules/misc/ids.nix

authored by Alexei Robyn and committed by Vladimír Čunát 4fa45188 4c792e58

+246
+1
lib/maintainers.nix
··· 14 AndersonTorres = "Anderson Torres <torres.anderson.85@gmail.com>"; 15 andres = "Andres Loeh <ksnixos@andres-loeh.de>"; 16 antono = "Antono Vasiljev <self@antono.info>"; 17 astsmtl = "Alexander Tsamutali <astsmtl@yandex.ru>"; 18 aszlig = "aszlig <aszlig@redmoonstudios.org>"; 19 bbenoist = "Baptist BENOIST <return_0@live.com>";
··· 14 AndersonTorres = "Anderson Torres <torres.anderson.85@gmail.com>"; 15 andres = "Andres Loeh <ksnixos@andres-loeh.de>"; 16 antono = "Antono Vasiljev <self@antono.info>"; 17 + arobyn = "Alexei Robyn <shados@shados.net>"; 18 astsmtl = "Alexander Tsamutali <astsmtl@yandex.ru>"; 19 aszlig = "aszlig <aszlig@redmoonstudios.org>"; 20 bbenoist = "Baptist BENOIST <return_0@live.com>";
+2
nixos/modules/misc/ids.nix
··· 131 starbound = 120; 132 hydra = 122; 133 spiped = 123; 134 135 # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! 136 ··· 236 grsecurity = 121; 237 hydra = 122; 238 spiped = 123; 239 240 # When adding a gid, make sure it doesn't match an existing uid. And don't use gids above 399! 241
··· 131 starbound = 120; 132 hydra = 122; 133 spiped = 123; 134 + teamspeak = 124; 135 136 # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! 137 ··· 237 grsecurity = 121; 238 hydra = 122; 239 spiped = 123; 240 + teamspeak = 124; 241 242 # When adding a gid, make sure it doesn't match an existing uid. And don't use gids above 399! 243
+1
nixos/modules/module-list.nix
··· 222 ./services/networking/syncthing.nix 223 ./services/networking/ssh/lshd.nix 224 ./services/networking/ssh/sshd.nix 225 ./services/networking/tftpd.nix 226 ./services/networking/unbound.nix 227 ./services/networking/vsftpd.nix
··· 222 ./services/networking/syncthing.nix 223 ./services/networking/ssh/lshd.nix 224 ./services/networking/ssh/sshd.nix 225 + ./services/networking/teamspeak3.nix 226 ./services/networking/tftpd.nix 227 ./services/networking/unbound.nix 228 ./services/networking/vsftpd.nix
+142
nixos/modules/services/networking/teamspeak3.nix
···
··· 1 + { config, pkgs, ... }: 2 + 3 + with pkgs.lib; 4 + 5 + let 6 + ts3 = pkgs.teamspeak_server; 7 + cfg = config.services.teamspeak3; 8 + user = "teamspeak"; 9 + group = "teamspeak"; 10 + in 11 + 12 + { 13 + 14 + ###### interface 15 + 16 + options = { 17 + 18 + services.teamspeak3 = { 19 + 20 + enable = mkOption { 21 + type = types.bool; 22 + default = false; 23 + description = '' 24 + Whether to run the Teamspeak3 voice communication server daemon. 25 + ''; 26 + }; 27 + 28 + dataDir = mkOption { 29 + type = types.path; 30 + default = "/var/lib/teamspeak3-server"; 31 + description = '' 32 + Directory to store TS3 database and other state/data files. 33 + ''; 34 + }; 35 + 36 + logPath = mkOption { 37 + type = types.path; 38 + default = "/var/log/teamspeak3-server/"; 39 + description = '' 40 + Directory to store log files in. 41 + ''; 42 + }; 43 + 44 + voiceIP = mkOption { 45 + type = types.str; 46 + default = "0.0.0.0"; 47 + description = '' 48 + IP on which the server instance will listen for incoming voice connections. Defaults to any IP. 49 + ''; 50 + }; 51 + 52 + defaultVoicePort = mkOption { 53 + type = types.int; 54 + default = 9987; 55 + description = '' 56 + 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. 57 + ''; 58 + }; 59 + 60 + fileTransferIP = mkOption { 61 + type = types.str; 62 + default = "0.0.0.0"; 63 + description = '' 64 + IP on which the server instance will listen for incoming file transfer connections. Defaults to any IP. 65 + ''; 66 + }; 67 + 68 + fileTransferPort = mkOption { 69 + type = types.int; 70 + default = 30033; 71 + description = '' 72 + TCP port opened for file transfers. 73 + ''; 74 + }; 75 + 76 + queryIP = mkOption { 77 + type = types.str; 78 + default = "0.0.0.0"; 79 + description = '' 80 + IP on which the server instance will listen for incoming ServerQuery connections. Defaults to any IP. 81 + ''; 82 + }; 83 + 84 + queryPort = mkOption { 85 + type = types.int; 86 + default = 10011; 87 + description = '' 88 + TCP port opened for ServerQuery connections. 89 + ''; 90 + }; 91 + 92 + }; 93 + 94 + }; 95 + 96 + 97 + ###### implementation 98 + 99 + config = mkIf cfg.enable { 100 + 101 + users.extraUsers.teamspeak = 102 + { name = "teamspeak"; 103 + description = "Teamspeak3 voice communication server daemon"; 104 + group = group; 105 + uid = config.ids.uids.teamspeak; 106 + }; 107 + 108 + users.extraGroups.teamspeak = 109 + { name = "teamspeak"; 110 + gid = config.ids.gids.teamspeak; 111 + }; 112 + 113 + systemd.services.teamspeak3-server = { 114 + description = "Teamspeak3 voice communication server daemon"; 115 + after = [ "network.target" ]; 116 + wantedBy = [ "multi-user.target" ]; 117 + 118 + preStart = '' 119 + mkdir -p ${cfg.dataDir} 120 + mkdir -p ${cfg.logPath} 121 + chown ${user}:${group} ${cfg.dataDir} 122 + chown ${user}:${group} ${cfg.logPath} 123 + ''; 124 + 125 + serviceConfig = 126 + { ExecStart = '' 127 + ${ts3}/bin/ts3server \ 128 + dbsqlpath=${ts3}/lib/teamspeak/sql/ logpath=${cfg.logPath} \ 129 + voice_ip=${cfg.voiceIP} default_voice_port=${toString cfg.defaultVoicePort} \ 130 + filetransfer_ip=${cfg.fileTransferIP} filetransfer_port=${toString cfg.fileTransferPort} \ 131 + query_ip=${cfg.queryIP} query_port=${toString cfg.queryPort} 132 + ''; 133 + WorkingDirectory = cfg.dataDir; 134 + User = user; 135 + Group = group; 136 + PermissionsStartOnly = true; # preStart needs to run with root permissions 137 + }; 138 + }; 139 + 140 + }; 141 + 142 + }
+99
pkgs/applications/networking/instant-messengers/teamspeak/server.nix
···
··· 1 + { stdenv, fetchurl, makeWrapper }: 2 + 3 + let 4 + 5 + version = "3.0.10.3"; 6 + 7 + arch = if stdenv.is64bit then "amd64" else "x86"; 8 + 9 + libDir = if stdenv.is64bit then "lib64" else "lib"; 10 + in 11 + 12 + stdenv.mkDerivation { 13 + name = "teamspeak-server-${version}"; 14 + 15 + src = fetchurl { 16 + urls = [ 17 + "http://dl.4players.de/ts/releases/${version}/teamspeak3-server_linux-${arch}-${version}.tar.gz" 18 + "http://teamspeak.gameserver.gamed.de/ts3/releases/${version}/teamspeak3-server_linux-${arch}-${version}.tar.gz" 19 + ]; 20 + sha256 = if stdenv.is64bit 21 + then "9606dd5c0c3677881b1aab833cb99f4f12ba08cc77ef4a97e9e282d9e10b0702" 22 + else "8b8921e0df04bf74068a51ae06d744f25d759a8c267864ceaf7633eb3f81dbe5"; 23 + }; 24 + 25 + buildInputs = [ makeWrapper ]; 26 + 27 + buildPhase = 28 + '' 29 + mv ts3server_linux_${arch} ts3server 30 + echo "patching ts3server" 31 + patchelf \ 32 + --interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" \ 33 + --set-rpath $(cat $NIX_GCC/nix-support/orig-gcc)/${libDir} \ 34 + --force-rpath \ 35 + ts3server 36 + ''; 37 + 38 + installPhase = 39 + '' 40 + # Delete unecessary libraries - these are provided by nixos. 41 + #rm *.so* 42 + 43 + # Install files. 44 + mkdir -p $out/lib/teamspeak 45 + mv * $out/lib/teamspeak/ 46 + 47 + # Make a symlink to the binary from bin. 48 + mkdir -p $out/bin/ 49 + ln -s $out/lib/teamspeak/ts3server $out/bin/ts3server 50 + 51 + wrapProgram $out/lib/teamspeak/ts3server --prefix LD_LIBRARY_PATH : $out/lib/teamspeak 52 + ''; 53 + 54 + dontStrip = true; 55 + dontPatchELF = true; 56 + 57 + meta = { 58 + description = "TeamSpeak voice communication server"; 59 + homepage = http://teamspeak.com/; 60 + license = stdenv.lib.licenses.unfreeRedistributable; 61 + platforms = stdenv.lib.platforms.linux; 62 + maintainers = [ stdenv.lib.maintainers.arobyn ]; 63 + }; 64 + } 65 + 66 + /* 67 + License issues: 68 + Date: Mon, 10 Dec 2007 19:55:16 -0500 69 + From: TeamSpeak Sales <sales@tritoncia.com> 70 + To: 'Marc Weber' <marco-oweber@gmx.de> 71 + Subject: RE: teamspeak on nix? 72 + 73 + Yes, that would be fine. As long as you are not renting servers or selling 74 + TeamSpeak then you are more than welcome to distribute it. 75 + 76 + Thank you, 77 + 78 + TeamSpeak Sales Team 79 + ________________________________ 80 + e-Mail: sales@tritoncia.com 81 + TeamSpeak: http://www.TeamSpeak.com 82 + Account Login: https://sales.TritonCIA.com/users 83 + 84 + 85 + 86 + -----Original Message----- 87 + From: Marc Weber [mailto:marco-oweber@gmx.de] 88 + Sent: Monday, December 10, 2007 5:03 PM 89 + To: sales@tritoncia.com 90 + Subject: teamspeak on nix? 91 + 92 + Hello, 93 + 94 + nix is very young software distribution system (http://nix.cs.uu.nl/) 95 + I'd like to ask wether you permit us to add teamspeak (server/ client?) 96 + 97 + Sincerly 98 + Marc Weber (small nix contributor) 99 + */
+1
pkgs/top-level/all-packages.nix
··· 9421 }; 9422 9423 teamspeak_client = callPackage ../applications/networking/instant-messengers/teamspeak/client.nix { }; 9424 9425 taskjuggler = callPackage ../applications/misc/taskjuggler { }; 9426
··· 9421 }; 9422 9423 teamspeak_client = callPackage ../applications/networking/instant-messengers/teamspeak/client.nix { }; 9424 + teamspeak_server = callPackage ../applications/networking/instant-messengers/teamspeak/server.nix { }; 9425 9426 taskjuggler = callPackage ../applications/misc/taskjuggler { }; 9427