Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions nixos/modules/services/games/terraria.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let
exit 0
fi

${getBin pkgs.tmux}/bin/tmux -S /var/lib/terraria/terraria.sock send-keys Enter exit Enter
${getBin pkgs.tmux}/bin/tmux -S ${cfg.dataDir}/terraria.sock send-keys Enter exit Enter
${getBin pkgs.coreutils}/bin/tail --pid="$1" -f /dev/null
'';
in
Expand All @@ -36,7 +36,7 @@ in
type = types.bool;
default = false;
description = ''
If enabled, starts a Terraria server. The server can be connected to via <literal>tmux -S /var/lib/terraria/terraria.sock attach</literal>
If enabled, starts a Terraria server. The server can be connected to via <literal>tmux -S ${cfg.dataDir}/terraria.sock attach</literal>
for administration by users who are a part of the <literal>terraria</literal> group (use <literal>C-b d</literal> shortcut to detach again).
'';
};
Expand Down Expand Up @@ -111,13 +111,19 @@ in
default = false;
description = "Disables automatic Universal Plug and Play.";
};
dataDir = mkOption {
type = types.str;
default = "/var/lib/terraria";
example = "/srv/terraria";
description = "Home directory for terraria.";
Comment thread
evanjs marked this conversation as resolved.
Outdated
};
};
};

config = mkIf cfg.enable {
users.users.terraria = {
description = "Terraria server service user";
home = "/var/lib/terraria";
home = cfg.dataDir;
createHome = true;
uid = config.ids.uids.terraria;
};
Expand All @@ -136,13 +142,13 @@ in
User = "terraria";
Type = "forking";
GuessMainPID = true;
ExecStart = "${getBin pkgs.tmux}/bin/tmux -S /var/lib/terraria/terraria.sock new -d ${pkgs.terraria-server}/bin/TerrariaServer ${concatStringsSep " " flags}";
ExecStart = "${getBin pkgs.tmux}/bin/tmux -S ${cfg.dataDir}/terraria.sock new -d ${pkgs.terraria-server}/bin/TerrariaServer ${concatStringsSep " " flags}";
ExecStop = "${stopScript} $MAINPID";
};

postStart = ''
${pkgs.coreutils}/bin/chmod 660 /var/lib/terraria/terraria.sock
${pkgs.coreutils}/bin/chgrp terraria /var/lib/terraria/terraria.sock
${pkgs.coreutils}/bin/chmod 660 ${cfg.dataDir}/terraria.sock
${pkgs.coreutils}/bin/chgrp terraria ${cfg.dataDir}/terraria.sock
'';
};
};
Expand Down