add withConfig for srcds

This commit is contained in:
Robin Appelman 2026-07-09 16:50:06 +02:00
commit 1d9037fc6c
3 changed files with 50 additions and 12 deletions

View file

@ -45,16 +45,23 @@
steam-depots = pkgs.steam-depots;
};
packages = inheritPkgs [
"ambuild"
"sourcepawn"
"sourcemod"
"sourcemod-includes"
"sourcemod-include-curl"
"sourcemod-include-library"
"sourcemod-include-steamworks"
"srcds-tf2"
];
packages =
inheritPkgs [
"ambuild"
"sourcepawn"
"sourcemod"
"sourcemod-includes"
"sourcemod-include-curl"
"sourcemod-include-library"
"sourcemod-include-steamworks"
"srcds-tf2"
]
// {
test = pkgs:
pkgs.srcds-tf2.withConfig {
hostname = "Spire Server";
};
};
checks = {
buildTestScript = {pkgs, ...}:

11
nix/srcds/cfg.nix Normal file
View file

@ -0,0 +1,11 @@
{
lib,
cfg,
name,
writeTextDir,
}: let
inherit (lib) mapAttrsToList concatStringsSep;
lines = mapAttrsToList (key: value: ''${key} "${value}"'') cfg;
text = concatStringsSep "\n" lines;
in
writeTextDir "tf/cfg/${name}" text

View file

@ -10,6 +10,8 @@
curlWithGnuTls,
steamworks-sdk-redist,
system,
callPackage,
srcds-tf2,
}: let
inherit (lib) importJSON map toString elem last replaceStrings naturalSort;
depotInputs = importJSON ./depots.json;
@ -59,12 +61,28 @@
}
);
makeWithConfig = base: config: let
configFile = callPackage ./cfg.nix {
name = "server.cfg";
cfg = config;
};
final = symlinkJoin {
name = "srcds-tf2-src";
paths = [base configFile];
passthru = makeWiths final;
};
in
final;
makeWiths = base: {
withConfig = makeWithConfig base;
};
mainProgram =
if system == "x86_64-linux"
then "srcds_run_64"
else "srcds_run";
in
stdenvNoCC.mkDerivation {
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "srcds-tf2";
version = timeToVersion time;
inherit src;
@ -96,6 +114,8 @@ in
runHook postInstall
'';
passthru = makeWiths srcds-tf2;
meta = with lib; {
inherit mainProgram;
description = "TF2 dedicated server";
@ -107,4 +127,4 @@ in
license = licenses.unfree;
platforms = ["x86_64-linux" "i686-linux"];
};
}
})