From 652a22f0dac0e45d1bfb0dafe954c9eb2f659b88 Mon Sep 17 00:00:00 2001 From: Evgeny Egorochkin Date: Wed, 15 Dec 2010 02:19:44 +0000 Subject: [PATCH] Ghost One: packaged. svn path=/nixos/trunk/; revision=25136 --- modules/misc/ids.nix | 2 + modules/module-list.nix | 1 + modules/services/games/ghost-one.nix | 103 +++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 modules/services/games/ghost-one.nix diff --git a/modules/misc/ids.nix b/modules/misc/ids.nix index f8219c23068b..22e62348394e 100644 --- a/modules/misc/ids.nix +++ b/modules/misc/ids.nix @@ -58,6 +58,7 @@ in foldingAtHome = 37; sabnzbd = 38; kdm = 39; + ghostOne = 40; # When adding a uid, make sure it doesn't match an existing gid. nixbld = 30000; # start of range of uids @@ -98,6 +99,7 @@ in privoxy = 32; disnix = 33; osgi = 34; + ghostOne = 40; # When adding a gid, make sure it doesn't match an existing uid. users = 100; diff --git a/modules/module-list.nix b/modules/module-list.nix index 0c7b9b6592f0..20ed8d085682 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -52,6 +52,7 @@ ./services/backup/sitecopy-backup.nix ./services/databases/mysql.nix ./services/databases/postgresql.nix + ./services/games/ghost-one.nix ./services/hardware/acpid.nix ./services/hardware/bluetooth.nix ./services/hardware/hal.nix diff --git a/modules/services/games/ghost-one.nix b/modules/services/games/ghost-one.nix new file mode 100644 index 000000000000..2b4610df29c1 --- /dev/null +++ b/modules/services/games/ghost-one.nix @@ -0,0 +1,103 @@ +{pkgs, config, ...}: +with pkgs.lib; +let + + cfg = config.services.ghostOne; + ghostUser = "ghostone"; + stateDir = "/var/lib/ghost-one"; +in +{ + + ###### interface + + options = { + services.ghostOne = { + + enable = mkOption { + default = false; + description = "Enable Ghost-One Warcraft3 game hosting server."; + }; + + language = mkOption { + default = "English"; + description = "The language of bot messages: English, Spanish, Russian, Serbian or Turkish."; + }; + + war3path = mkOption { + default = ""; + description = '' + The path to your local Warcraft III directory, which must contain war3.exe, storm.dll, and game.dll. + ''; + }; + + mappath = mkOption { + default = ""; + description = '' + The path to the directory where you keep your map files. GHost One doesn't require + map files but if it has access to them it can send them to players and automatically + calculate most map config values. GHost One will search [bot_mappath + map_localpath] + for the map file (map_localpath is set in each map's config file). + ''; + }; + + config = mkOption { + default = ""; + description = "Extra configuration options."; + }; + + }; + }; + + ###### implementation + + config = mkIf cfg.enable { + + users.extraUsers = singleton + { name = ghostUser; + uid = config.ids.uids.ghostOne; + description = "Ghost One game server user"; + home = stateDir; + }; + + users.extraGroups = singleton + { name = ghostUser; + gid = config.ids.gids.ghostOne; + }; + + services.ghostOne.config = '' +# bot_log = /dev/stderr + bot_language = ${pkgs.ghostOne}/share/ghost-one/languages/${cfg.language}.cfg + bot_war3path = ${cfg.war3path} + + bot_mapcfgpath = mapcfgs + bot_savegamepath = savegames + bot_mappath = ${cfg.mappath} + bot_replaypath = replays + ''; + + jobs.ghostOne = { + name = "ghost-one"; + script = '' + mkdir -p ${stateDir} + cd ${stateDir} + chown ${ghostUser}:${ghostUser} . + + mkdir -p mapcfgs + chown ${ghostUser}:${ghostUser} mapcfgs + + mkdir -p replays + chown ${ghostUser}:${ghostUser} replays + + mkdir -p savegames + chown ${ghostUser}:${ghostUser} savegames + + ln -sf ${pkgs.writeText "ghost.cfg" cfg.config} ghost.cfg + ln -sf ${pkgs.ghostOne}/share/ghost-one/ip-to-country.csv + ${pkgs.su}/bin/su -s ${pkgs.stdenv.shell} ${ghostUser} \ + -c "LANG=C ${pkgs.ghostOne}/bin/ghost++" + ''; + }; + + }; + +} \ No newline at end of file