-
-
Save mtrsk/82f90a71655592e6c5e80a57f8a097e7 to your computer and use it in GitHub Desktop.
nixpkgs terraria module - add home config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, lib, pkgs, ... }: | |
{ | |
services.sshd.enable = true; | |
services.terraria = { | |
enable = true; | |
home = "/srv/terraria"; | |
}; | |
nixpkgs.config.allowUnfree = true; | |
networking.firewall.allowedTCPPorts = [ 80 ]; | |
users.users.root.password = "nixos"; | |
services.openssh.permitRootLogin = lib.mkDefault "yes"; | |
#services.mingetty.autologinUser = lib.mkDefault "root"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./nixos-generate -c configuration.nix -f vm-nogui --run -I nixpkgs=/home/evanjs/src/nixpkgs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/nixos/modules/services/games/terraria.nix b/nixos/modules/services/games/terraria.nix | |
index a59b74c0b4c..6572e37ba04 100644 | |
--- a/nixos/modules/services/games/terraria.nix | |
+++ b/nixos/modules/services/games/terraria.nix | |
@@ -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.home}/terraria.sock send-keys Enter exit Enter | |
${getBin pkgs.coreutils}/bin/tail --pid="$1" -f /dev/null | |
''; | |
in | |
@@ -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.home}/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). | |
''; | |
}; | |
@@ -111,13 +111,18 @@ in | |
default = false; | |
description = "Disables automatic Universal Plug and Play."; | |
}; | |
+ home = mkOption { | |
+ type = types.str; | |
+ default = "/var/lib/terraria"; | |
+ description = "Home directory for terraria."; | |
+ }; | |
}; | |
}; | |
config = mkIf cfg.enable { | |
users.users.terraria = { | |
description = "Terraria server service user"; | |
- home = "/var/lib/terraria"; | |
+ home = cfg.home; | |
createHome = true; | |
uid = config.ids.uids.terraria; | |
}; | |
@@ -136,13 +141,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.home}/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.home}/terraria.sock | |
+ ${pkgs.coreutils}/bin/chgrp terraria ${cfg.home}/terraria.sock | |
''; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment