mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
chore(minecraft): module cleanup
This commit is contained in:
parent
e07f689dec
commit
7a7057492c
9 changed files with 426 additions and 207 deletions
61
modules/system/exports/minecraft-java.nix
Normal file
61
modules/system/exports/minecraft-java.nix
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
config.exports.services.minecraft = {config, ...}: let
|
||||
mkAssertion = f: nixosConfig: let
|
||||
cfg = nixosConfig.services.${config.nixos.serviceAttr};
|
||||
in
|
||||
f nixosConfig cfg;
|
||||
in {
|
||||
displayName = "Minecraft";
|
||||
nixos = {
|
||||
serviceAttr = "minecraft-katsink-server";
|
||||
assertions = mkIf config.enable [
|
||||
(mkAssertion (nixosConfig: cfg: {
|
||||
assertion = config.ports.default.port == cfg.port;
|
||||
message = "server-port mismatch";
|
||||
}))
|
||||
(mkAssertion (nixosConfig: cfg: {
|
||||
assertion = config.ports.rcon.enable == cfg.serverProperties.enable-rcon or false;
|
||||
message = "enable-rcon mismatch";
|
||||
}))
|
||||
(mkAssertion (nixosConfig: cfg: {
|
||||
assertion = (! cfg.serverProperties.enable-rcon or false) || config.ports.rcon.port == cfg.serverProperties."rcon.port" or 25575;
|
||||
message = "rcon.port mismatch";
|
||||
}))
|
||||
(mkAssertion (nixosConfig: cfg: {
|
||||
assertion = config.ports.query.enable == cfg.serverProperties.enable-query or false;
|
||||
message = "enable-query mismatch";
|
||||
}))
|
||||
(mkAssertion (nixosConfig: cfg: {
|
||||
assertion = (! cfg.serverProperties.enable-query or false) || config.ports.query.port == cfg.serverProperties."query.port" or 25565;
|
||||
message = "query.port mismatch";
|
||||
}))
|
||||
];
|
||||
};
|
||||
defaults.port.listen = mkAlmostOptionDefault "local";
|
||||
ports = {
|
||||
default = {
|
||||
port = mkAlmostOptionDefault 25565;
|
||||
transport = "tcp";
|
||||
};
|
||||
rcon = {
|
||||
enable = mkAlmostOptionDefault false;
|
||||
port = mkAlmostOptionDefault 25575;
|
||||
transport = "tcp";
|
||||
listen = mkAlmostOptionDefault "int";
|
||||
};
|
||||
query = {
|
||||
enable = mkAlmostOptionDefault false;
|
||||
port = mkAlmostOptionDefault config.ports.default.port;
|
||||
transport = "udp";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue