nixos/terraria: use config file instead of passing flags #314621
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of changes
This PR revamps the
services.terraria
NixOS module.The first commit fixes the
ExecStop
script of the service.When launching the server without configuring a world to start automatically, the server will show a world selection prompt. The
ExecStop
script would unconditionally send theexit
command to thetmux
session, even if the server was still in the world selection phase (during which the exit command doesn't work).This PR makes it so that if we're still in the world selection phase (checked using shell pattern matching), we will just send a
kill-session
command instead, since we've got nothing to save.Some other small changes include factoring out
tmux -S terraria.sock
calls and usingwriteShellScript
instead ofwriteScript
.The other commit moves the module over to using a config file, instead of passing a bunch of command line flags.
The benefit of this other than readability is that the config file has more settings than what could be configured using the flags.
The few extra options I've implemented were the
autoCreatedWorldSeed
andautoCreatedWorldDifficulty
.These
autoCreated*
options should probably be factored out intoautocreate.worldType
autocreate.seed
andautocreate.difficulty
, but I haven't done them yet.I added all supported flags to the list, but didn't implement all of them. I'll do that in another PR.
I also removed the top-level
with lib;
which is an anti-pattern.@ncfavier - the other maintainer of the
terraria-server
package.Not sure how else I should ping, since this module is very outdated.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.