at 15.09-beta 2.8 kB view raw
1{ config, lib, pkgs, ... }: 2with lib; 3let 4 5 cfg = config.services.ghostOne; 6 ghostUser = "ghostone"; 7 stateDir = "/var/lib/ghost-one"; 8 9in 10{ 11 12 ###### interface 13 14 options = { 15 services.ghostOne = { 16 17 enable = mkOption { 18 default = false; 19 description = "Enable Ghost-One Warcraft3 game hosting server."; 20 }; 21 22 language = mkOption { 23 default = "English"; 24 type = types.addCheck types.str 25 (lang: elem lang [ "English" "Spanish" "Russian" "Serbian" "Turkish" ]); 26 description = "The language of bot messages: English, Spanish, Russian, Serbian or Turkish."; 27 }; 28 29 war3path = mkOption { 30 default = ""; 31 description = '' 32 The path to your local Warcraft III directory, which must contain war3.exe, storm.dll, and game.dll. 33 ''; 34 }; 35 36 mappath = mkOption { 37 default = ""; 38 description = '' 39 The path to the directory where you keep your map files. GHost One doesn't require 40 map files but if it has access to them it can send them to players and automatically 41 calculate most map config values. GHost One will search [bot_mappath + map_localpath] 42 for the map file (map_localpath is set in each map's config file). 43 ''; 44 }; 45 46 config = mkOption { 47 default = ""; 48 description = "Extra configuration options."; 49 }; 50 51 }; 52 }; 53 54 ###### implementation 55 56 config = mkIf cfg.enable { 57 58 users.extraUsers = singleton 59 { name = ghostUser; 60 uid = config.ids.uids.ghostone; 61 description = "Ghost One game server user"; 62 home = stateDir; 63 }; 64 65 users.extraGroups = singleton 66 { name = ghostUser; 67 gid = config.ids.gids.ghostone; 68 }; 69 70 services.ghostOne.config = '' 71# bot_log = /dev/stderr 72 bot_language = ${pkgs.ghostOne}/share/ghost-one/languages/${cfg.language}.cfg 73 bot_war3path = ${cfg.war3path} 74 75 bot_mapcfgpath = mapcfgs 76 bot_savegamepath = savegames 77 bot_mappath = ${cfg.mappath} 78 bot_replaypath = replays 79 ''; 80 81 jobs.ghostOne = { 82 name = "ghost-one"; 83 script = '' 84 mkdir -p ${stateDir} 85 cd ${stateDir} 86 chown ${ghostUser}:${ghostUser} . 87 88 mkdir -p mapcfgs 89 chown ${ghostUser}:${ghostUser} mapcfgs 90 91 mkdir -p replays 92 chown ${ghostUser}:${ghostUser} replays 93 94 mkdir -p savegames 95 chown ${ghostUser}:${ghostUser} savegames 96 97 ln -sf ${pkgs.writeText "ghost.cfg" cfg.config} ghost.cfg 98 ln -sf ${pkgs.ghostOne}/share/ghost-one/ip-to-country.csv 99 ${pkgs.su}/bin/su -s ${pkgs.stdenv.shell} ${ghostUser} \ 100 -c "LANG=C ${pkgs.ghostOne}/bin/ghost++" 101 ''; 102 }; 103 104 }; 105 106}