refactor(steamcmd): constrain service names

This commit was merged in pull request #187.
This commit is contained in:
2026-10-15 14:13:07 -04:00
parent 1397576538
commit c44769ff70
2 changed files with 5 additions and 4 deletions

View File

@@ -15,9 +15,9 @@
};
serviceName = lib.mkOption {
type = lib.types.str;
type = lib.types.strMatching "[a-z0-9][a-z0-9-]*";
example = "valheim";
description = "Name of the systemd service that runs the game server.";
description = "Lowercase systemd service basename for the game server.";
};
appId = lib.mkOption {
@@ -87,7 +87,7 @@
prepareScript = pkgs.writeShellScript "steamcmd-${service.serviceName}-prepare" ''
set -eu
${pkgs.coreutils}/bin/install -d \
${lib.getExe' pkgs.coreutils "install"} -d \
-o ${user} \
-g ${group} \
-m 0770 \
@@ -155,7 +155,7 @@
wantedBy = lib.mkIf service.autoStart [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.systemd}/bin/systemctl --no-block start ${service.serviceName}.service";
ExecStart = "${lib.getExe' pkgs.systemd "systemctl"} --no-block start ${service.serviceName}.service";
};
};