blob: 5b29d36d1839b518d8f40463780d7e5fe8bb09d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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);
};
};
}
|