diff options
author | yuuko <yuuko@partyvan.io> | 2024-08-29 21:51:04 -0700 |
---|---|---|
committer | yuuko <yuuko@partyvan.io> | 2024-08-29 21:51:04 -0700 |
commit | 56449e59d7aabd1c06fb67a51a1e129b55cb9270 (patch) | |
tree | 19f3faf805e9b6461a5940d1a050d13e5271ef55 /srcds-pkgs/sourcemod |
break out of system config
Diffstat (limited to 'srcds-pkgs/sourcemod')
-rw-r--r-- | srcds-pkgs/sourcemod/default.nix | 82 | ||||
-rw-r--r-- | srcds-pkgs/sourcemod/setup-hook.sh | 16 |
2 files changed, 98 insertions, 0 deletions
diff --git a/srcds-pkgs/sourcemod/default.nix b/srcds-pkgs/sourcemod/default.nix new file mode 100644 index 0000000..90c31f9 --- /dev/null +++ b/srcds-pkgs/sourcemod/default.nix @@ -0,0 +1,82 @@ +{ lib, multiStdenv, pkgsi686Linux +, writeShellScript +, fetchFromGitHub, ed +, hl2sdk, ambuild, metamod-source, libfinite +, mysql_5_5 +}: let + inherit (pkgsi686Linux) zlib; + owner = "alliedmodders"; + buildno = "6968"; +in multiStdenv.mkDerivation rec { + pname = "sourcemod"; + version = "1.11_${buildno}"; + + src = fetchFromGitHub rec { + inherit owner; + repo = pname; + rev = "13510eab809a98b6a62354fc9848641"; + fetchSubmodules = true; + hash = "sha256-leV0Q7g5bnJljzQxv3z6t5p/1d9TxILPvIuSYuq8LmE="; + }; + + nativeBuildInputs = [ ambuild ed ]; + buildInputs = [ zlib mysql_5_5 ]; + + hardeningDisable = [ "all" ]; + + CXXFLAGS="-Wno-error=sign-compare -Wno-error=ignored-attributes"; + + postPatch = '' + mkdir .git + echo "ref: refs/heads/main" > .git/HEAD + ed tools/buildbot/generate_headers.py <<EOF + /^def get_git_version/;/return/a + def get_git_version(): + return '${buildno}', '${builtins.substring 0 7 src.rev}', '${src.rev}' + . + w + EOF + for i in sdktools dhooks sdkhooks; do + sed -i '/invalid-offsetof/s,no-,no-error=,' extensions/$i/AMBuilder + done + ed AMBuildScript <<EOF + /'mathlib.a'/s|$|, '${libfinite}',| + w + EOF + ''; + + configurePhase = '' + ln -s ${hl2sdk} ${hl2sdk.name} + ln -s ${metamod-source}/include metamod-source + mkdir -p build + cd build + python ../configure.py --sdks present --mysql-path ${mysql_5_5} + ''; + + buildPhase = '' + ambuild + ''; + + installPhase = '' + mkdir $out + mv package $out/share + cd $out/share/addons/sourcemod/plugins + mv *.smx disabled/ + mkdir -p $out/bin + cd $out/bin + cp ${writeShellScript "spcomp" '' + echo OUT/share/addons/sourcemod/scripting/spcomp $SPCOMPFLAGS "$@" + OUT/share/addons/sourcemod/scripting/spcomp $SPCOMPFLAGS "$@" + ''} ./spcomp + substituteInPlace ./spcomp --replace OUT "$out" + ''; + + setupHook = ./setup-hook.sh; + + meta = with lib; { + description = "Source Engine scripting and administration"; + homepage = "https://github.com/${owner}/${pname}"; + platforms = platforms.unix; + license = licenses.gpl3; + }; +} diff --git a/srcds-pkgs/sourcemod/setup-hook.sh b/srcds-pkgs/sourcemod/setup-hook.sh new file mode 100644 index 0000000..17d8617 --- /dev/null +++ b/srcds-pkgs/sourcemod/setup-hook.sh @@ -0,0 +1,16 @@ +SPCOMPFLAGS=${SPCOMPFLAGS:-} +dontUseSourcepawnFindHeaders=${dontUseSourcepawnFindHeaders:-} +sourcepawnFindHeaders(){ + [ -n "${dontUseSourcepawnFindHeaders:-}" ] && return + for plug in $buildInputs; do + local ipath="$plug/share/addons/sourcemod/scripting/include" + if [ -d "$ipath" ]; then + echo "found sourcepawn headers: \"$ipath\"" + SPCOMPFLAGS="$SPCOMPFLAGS -i $ipath" + fi + done + dontUseSourcepawnFindHeaders=1 + export SPCOMPFLAGS dontUseSourcepawnFindHeaders +} + +addEnvHooks "$targetOffset" sourcepawnFindHeaders |