My NixOS Teeworlds servers management module | |
2024-11-10 | |
Last edit: 2024-11-10 | |
--------------------- | |
So I created a NixOS module to declare Teeworlds servers with their Nix configu… | |
Why did I do this? Simply because I saw a | |
video](https://www.youtube.com/watch?v=Fph7SMldxpI) from [Vimjoyer | |
that presented a NixOs module for declaring multiple Minecraft servers. I coul… | |
The module is open-source and available via a | |
GitHub repository | |
. In this repository there are also some packages providing a server with parti… | |
They can also be run with the `nix run` command, for example, you could create … | |
fng2 | |
server with the following command. | |
```bash | |
nix run github:theobori/nix-teeworlds#fng2-server | |
``` | |
The module is user-friendly and fairly intuitive to configure. For example, to … | |
fng2 | |
server, you could write a Nix expression like this. | |
```nix | |
{ pkgs, ... }: | |
{ | |
services.nix-teeworlds = { | |
enable = true; | |
openFirewall = true; | |
servers = { | |
my-fng = { | |
enable = true; | |
package = pkgs.fng2-server; | |
extraConfig = '' | |
password "1234" | |
''; | |
externalConsole = { | |
enable = true; | |
port = 1111; | |
password = "hello"; | |
outputLevel = 2; | |
}; | |
settings = { | |
name = "My FNG server from NixOS"; | |
port = 8305; | |
maxClients = 16; | |
}; | |
game = { | |
gameType = "fng2"; | |
map = "AliveFNG"; | |
scoreLimit = 800; | |
}; | |
votes = { | |
"Say hello" = { | |
commands = [ | |
"say hello" | |
"say world" | |
"say !!" | |
]; | |
}; | |
"Map IIT_Edited" = { | |
commands = [ "sv_map IIT_Edited" ]; | |
}; | |
"Empty vote" = { | |
commands = [ ]; | |
}; | |
}; | |
}; | |
}; | |
}; | |
} | |
``` | |
To access `services.nix-teeworlds`, you can import the module as specified in t… | |
GitHub repository | |
. | |
Inside your `flake.nix`, you can start by adding the following lines. | |
```nix | |
{ | |
inputs = { | |
nix-teeworlds.url = "github:theobori/nix-teeworlds"; | |
}; | |
} | |
``` | |
You can then include the module and its default overlay in the system configura… | |
```nix | |
{ inputs, ... }: { | |
imports = with inputs; [ nix-teeworlds.nixosModules.nix-teeworlds ]; | |
nixpkgs.overlays = with inputs; [ nix-teeworlds.overlays.default ]; | |
} | |
``` | |
Under the hood, each teeworlds server is managed by a systemd service unit, whi… | |
Evaluation of the module may return an error if the ports of the different serv… | |
in the code | |
. | |
Anyone is free to contribute to the source code. For more details, please visit… | |
GitHub repository | |
. | |