diff options
author | tdback <tyler@tdback.net> | 2025-03-04 23:03:49 -0500 |
---|---|---|
committer | tdback <tyler@tdback.net> | 2025-03-04 23:03:49 -0500 |
commit | b2c380327d58dc4c7add6dbd735d30f00ce48c21 (patch) | |
tree | dd23b18683f38f5209915aa5f3a90ad944f95b3f /modules/services/xonotic/default.nix | |
parent | a0573135c21f8b4a6ad704bb672509c291405e36 (diff) |
services: add xonotic server module
Diffstat (limited to 'modules/services/xonotic/default.nix')
-rw-r--r-- | modules/services/xonotic/default.nix | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/modules/services/xonotic/default.nix b/modules/services/xonotic/default.nix new file mode 100644 index 0000000..5b29d36 --- /dev/null +++ b/modules/services/xonotic/default.nix @@ -0,0 +1,64 @@ +{ + config, + lib, + pkgs, + ... +}: +with lib; +let + cfg = config.modules.services.xonotic; + setMutators = mutators: mapAttrs' (m: v: nameValuePair ("g_" + m) (if v then 1 else 0)) mutators; +in +{ + options.modules.services.xonotic = { + enable = mkEnableOption "xonotic"; + package = mkPackageOption pkgs "xonotic-dedicated" { }; + port = mkOption { + default = 26000; + type = types.int; + }; + hostname = mkOption { + default = "Xonotic Server"; + type = types.str; + }; + public = mkOption { + default = true; + type = types.bool; + }; + motd = mkOption { + default = ""; + type = types.str; + }; + maxplayers = mkOption { + default = 8; + type = types.int; + }; + minplayers = mkOption { + default = 4; + type = types.int; + }; + g_mutators = mkOption { + default = { }; + type = types.attrsOf types.bool; + description = "Enable server mutators. Refer to upstream configuration."; + }; + }; + + config = mkIf cfg.enable { + services.xonotic = { + enable = true; + package = cfg.package; + openFirewall = true; + settings = { + net_address = "0.0.0.0"; + port = cfg.port; + hostname = cfg.hostname; + sv_public = if cfg.public then 1 else 0; + sv_motd = cfg.motd; + maxplayers = cfg.maxplayers; + minplayers = cfg.minplayers; + minplayers_per_team = cfg.minplayers / 2; + } // (setMutators cfg.g_mutators); + }; + }; +} |