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

@@ -67,3 +67,4 @@
- On Pikachu, `uptime` does not support `-s`. Use `who -b` to report the boot time. - On Pikachu, `uptime` does not support `-s`. Use `who -b` to report the boot time.
- Evaluating a NixOS guest's inner `config.services.nginx` can force incomplete ACME values. - Evaluating a NixOS guest's inner `config.services.nginx` can force incomplete ACME values.
Evaluate the parent host's `config.system.build.toplevel` to validate an ACME-enabled guest. Evaluate the parent host's `config.system.build.toplevel` to validate an ACME-enabled guest.
- `pkgs.systemd` does not set `meta.mainProgram`. Use `lib.getExe' pkgs.systemd "systemctl"` instead of `lib.getExe pkgs.systemd`.

View File

@@ -15,9 +15,9 @@
}; };
serviceName = lib.mkOption { serviceName = lib.mkOption {
type = lib.types.str; type = lib.types.strMatching "[a-z0-9][a-z0-9-]*";
example = "valheim"; 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 { appId = lib.mkOption {
@@ -87,7 +87,7 @@
prepareScript = pkgs.writeShellScript "steamcmd-${service.serviceName}-prepare" '' prepareScript = pkgs.writeShellScript "steamcmd-${service.serviceName}-prepare" ''
set -eu set -eu
${pkgs.coreutils}/bin/install -d \ ${lib.getExe' pkgs.coreutils "install"} -d \
-o ${user} \ -o ${user} \
-g ${group} \ -g ${group} \
-m 0770 \ -m 0770 \
@@ -155,7 +155,7 @@
wantedBy = lib.mkIf service.autoStart [ "multi-user.target" ]; wantedBy = lib.mkIf service.autoStart [ "multi-user.target" ];
serviceConfig = { serviceConfig = {
Type = "oneshot"; 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";
}; };
}; };