migrate arma configs to module
This commit is contained in:
parent
83e62adf85
commit
69e69c2b7f
3 changed files with 78 additions and 30 deletions
64
modules/nixos/common/arma.nix
Normal file
64
modules/nixos/common/arma.nix
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.services.arma;
|
||||
in
|
||||
{
|
||||
options.services.arma = {
|
||||
enable = lib.mkEnableOption "enable arma";
|
||||
dataDir = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "/var/lib/steam";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
nixpkgs.config.allowUnfreePredicate =
|
||||
pkg:
|
||||
builtins.elem (lib.getName pkg) [
|
||||
"steamcmd"
|
||||
"steam-run"
|
||||
"steam-unwrapped"
|
||||
];
|
||||
# Create steam user
|
||||
users = {
|
||||
users.steam = {
|
||||
isSystemUser = true;
|
||||
home = cfg.dataDir;
|
||||
createHome = true;
|
||||
shell = pkgs.bash;
|
||||
group = "steam";
|
||||
};
|
||||
groups.steam = { };
|
||||
};
|
||||
systemd.tmpfiles.rules = [
|
||||
# "d /var/lib/steam 0755 steam steam -"
|
||||
"d ${cfg.dataDir}/reforger/configs 0755 steam steam -"
|
||||
"d ${cfg.dataDir}/reforger/profile 0755 steam steam -"
|
||||
"d ${cfg.dataDir}/reforger/workshop 0755 steam steam -"
|
||||
];
|
||||
systemd.services = {
|
||||
arma = {
|
||||
description = "arma game server";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
environment = {
|
||||
ARMA_DIR = "${cfg.dataDir}";
|
||||
};
|
||||
path = with pkgs; [
|
||||
curl
|
||||
steamcmd
|
||||
steam-run
|
||||
];
|
||||
preStart = "${pkgs.arma-scripts}/scripts/update.sh";
|
||||
serviceConfig = {
|
||||
User = "steam";
|
||||
WorkingDirectory = "${cfg.dataDir}/reforger";
|
||||
ExecStart = "${pkgs.arma-scripts}/scripts/start.sh";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue