diff --git a/hosts/dark-firepit/default.nix b/hosts/dark-firepit/default.nix index 2ea9cec..68728f4 100644 --- a/hosts/dark-firepit/default.nix +++ b/hosts/dark-firepit/default.nix @@ -139,10 +139,109 @@ in { addonDir = "/var/lib/srb2k/firepit/"; fileNames = attrNames (readDir (/. + addonDir)); addonFileNames = filter (n: hasSuffix ".lua" n || hasSuffix ".kart" n || hasSuffix ".pk3" n || hasSuffix ".wad" n) fileNames; + colors = builtins.fromJSON ''{ + "white": "\u0080", + "purple": "\u0081", + "yellow": "\u0082", + "green": "\u0083", + "blue": "\u0084", + "red": "\u0085", + "gray": "\u0086", + "orange": "\u0087", + "cyan": "\u0088", + "lavender": "\u0089", + "gold": "\u008a", + "lime": "\u008b", + "steel": "\u008c", + "pink": "\u008d", + "brown": "\u008e", + "peach": "\u008f" + }''; + colorsLua = { + white = "\\128"; + purple = "\\129"; + yellow = "\\130"; + green = "\\131"; + blue = "\\132"; + red = "\\133"; + gray = "\\134"; + orange = "\\135"; + cyan = "\\136"; + lavender = "\\137"; + gold = "\\138"; + lime = "\\139"; + steel = "\\140"; + pink = "\\141"; + brown = "\\142"; + peach = "\\143"; + }; in { enable = true; - advertise = false; + advertise = true; addons = map (n: "${addonDir}${n}") addonFileNames; + config = { + maxplayers = 16; + http_source = "https://yugoslavia.best/srb2kaddons/"; + maxsend = "max"; + servername = with colors; "${white}[${cyan}EU${white}] ${lime}yugoslavia.best"; + server_contact = "oat.zone||home of bar"; + }; + serv = with colorsLua; '' + kmp_hardsneakers on + kmp_extendflashtics on + kmp_floatingitemfuse on + kmp_hyudoro on + kmp_haste on + kmp_respawnpoints on + kmp_battleaccel on + maxsend max + fr_enabled off + khaosenable off + + wait 1 + + fd_finishkill off + fd_hitkill off + + wait 1 + + nametag_star on + + wait 1 + + hm_bail on + hm_timelimit 8 + hm_motd on + hm_motd_nag on + hm_motd_name "${lime}yugoslavia.best" + hm_motd_tagline "home of bar" + hm_motd_contact "oat.zone" + hm_restat on + hm_restat_notify on + hm_votable exitlevel + hm_vote_timer 20 + + wait 1 + + hm_specbomb on + + hm_scoreboard on + hm_scoreboard_humor on + wait 1 + hm_scoreboard_addline "${lime}yugoslavia.best${white}: home of bar" + wait 1 + hm_scoreboard_addline " hosted by ${lime}oat.zone" + wait 1 + hm_scoreboard_addline "casual server, anything goes," + hm_scoreboard_addline "feel free to suggest mods to" + wait 1 + hm_scoreboard_addline "${pink}oatmealine#5397 ${white}/ ${pink}oatmealine@disroot.org" + //hm_scoreboard_addline "${white}80${purple}81${yellow}82${green}83${blue}84${red}85${gray}86${orange}87${cyan}88${lavender}89${gold}8a${lime}8b${steel}8c${pink}8d${brown}8e${peach}8f" + + wait 1 + + hf_displaymode 3 + ''; #" }; minecraft = { diff --git a/modules/services/srb2k.nix b/modules/services/srb2k.nix index 0a21d8b..875ce5d 100644 --- a/modules/services/srb2k.nix +++ b/modules/services/srb2k.nix @@ -12,6 +12,7 @@ let "+advertise ${toString (if cfg.advertise then 1 else 0)}" "-port ${toString cfg.port}" "-serverport ${toString cfg.port}" + "-home ${cfg.dataDir}" ] ++ cfg.flags; in { options.modules.services.srb2k = { @@ -28,7 +29,11 @@ in { dataDir = mkOption { type = types.str or types.path; default = "/var/lib/srb2k"; - description = "The directory where srb2k will store addons and state information"; + description = '' + The directory where SRB2K will store state information. + Due to limitations with the game itself, the game will + store state information in a subfolder named '.srb2kart'. + ''; }; port = mkOption { @@ -40,7 +45,7 @@ in { addons = mkOption { type = types.listOf (types.str or types.path); default = []; - description = "Locations of srb2k addons and also fungus spore tasty in your body they grow happy you grow happy"; + description = "Locations of SRB2K addons and also fungus spore tasty in your body they grow happy you grow happy"; }; advertise = mkOption { @@ -66,6 +71,38 @@ in { default = true; description = "Automatically open ports in the firewall."; }; + + config = mkOption { + type = with types; attrsOf (oneOf [ bool int str ]); + default = {}; + example = literalExpression '' + { + maxplayers = 16; + http_source = "https://yugoslavia.best/srb2kaddons/"; + maxsend = "max"; + servername = with colors; "[EU] ''${lime}yugoslavia.best"; + server_contact = "oat.zone"; + } + ''; #" + description = "Options to put into dkartconfig.cfg"; + }; + + serv = mkOption { + type = types.str; + default = ""; + description = "Additional commands to run on startup via kartserv.cfg"; + example = literalExpression '' + with colors; ''' + fr_enabled off + khaosenable off + + hm_motd on + hm_motd_nag on + hm_motd_name "''${lime}yugoslavia.best" + hm_motd_tagline "home of bar" + ''' + ''; + }; }; config = mkIf cfg.enable { @@ -98,6 +135,20 @@ in { ${tmux} -S ${tmuxSock} send-keys quit Enter ''; + + kartConfig = + let + cfgToString = v: if builtins.isBool v then boolToString v else toString v; + in + pkgs.writeText "kartconfig.cfg" ( + '' + // SRB2Kart configuration file. + // Managed by NixOS configuration + '' + + concatStringsSep "\n" (mapAttrsToList (n: v: "${n} \"${cfgToString v}\"") cfg.config) + ); + + kartServ = pkgs.writeText "kartserv.cfg" cfg.serv; in { description = "srb2k server =)"; wantedBy = mkIf cfg.autoStart [ "multi-user.target" ]; @@ -114,8 +165,13 @@ in { }; preStart = '' - ${pkgs.coreutils}/bin/chown srb2k:srb2k ${cfg.dataDir} - ${pkgs.coreutils}/bin/chmod -R 775 ${cfg.dataDir} + umask u=rwx,g=rwx,o=rx + mkdir -p ${cfg.dataDir}/.srb2kart + cd ${cfg.dataDir} + ${if cfg.config != {} then "ln -sf ${kartConfig} .srb2kart/dkartconfig.cfg" else ""} + ${if cfg.serv != "" then "ln -sf ${kartServ} .srb2kart/kartserv.cfg" else ""} + ${pkgs.coreutils}/bin/chown srb2k:srb2k . + ${pkgs.coreutils}/bin/chmod -R 775 . ''; postStart = ''