From 56449e59d7aabd1c06fb67a51a1e129b55cb9270 Mon Sep 17 00:00:00 2001 From: yuuko Date: Thu, 29 Aug 2024 21:51:04 -0700 Subject: break out of system config --- srcds-pkgs/build-sm-plugin.nix | 71 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 srcds-pkgs/build-sm-plugin.nix (limited to 'srcds-pkgs/build-sm-plugin.nix') diff --git a/srcds-pkgs/build-sm-plugin.nix b/srcds-pkgs/build-sm-plugin.nix new file mode 100644 index 0000000..d55338d --- /dev/null +++ b/srcds-pkgs/build-sm-plugin.nix @@ -0,0 +1,71 @@ +/* there is a lot of hideous directory-shuffling bureaucracy here. it + * encompasses all that has been found necessary out in the wild. sourcemod + * plugins following a sane standard project structure is a fairly recent + * development. + */ +{ lib, stdenvNoCC, sourcemod }: +{ scriptingPath ? "scripting" +, includePath ? "scripting/include" +, pluginsPath ? "plugins" +, translationsPath ? "translations" +, gamedataPath ? "gamedata" +, removePrebuilt ? true +, nativeBuildInputs ? [] +, ... +}@args: +let + inherit (lib) hasSuffix; +in +assert !hasSuffix "/" scriptingPath; +assert !hasSuffix "/" includePath; +assert !hasSuffix "/" pluginsPath; +assert !hasSuffix "/" translationsPath; +assert !hasSuffix "/" gamedataPath; +stdenvNoCC.mkDerivation ({ + inherit + scriptingPath includePath pluginsPath translationsPath gamedataPath + removePrebuilt; + configurePhase = '' + runHook preConfigure + source <(for d in scripting include plugins translations gamedata; do + echo "''${d}Path=$PWD/"\$"''${d}Path" + done) + cd /build + for p in scripting plugins translations gamedata; do + path="$(eval echo \$"''${p}Path")" + [ -d "$path" ] && cp -rT "$path" ./"$p" + done + case "$includePath" in + "$scriptingPath/include") :;; + "$scriptingPath"/*) echo TODO; exit 1;; + *) cp -r "$includePath" ./scripting/include;; + esac + [ -n "''${removePrebuilt:-}" ] && rm -f plugins/*.smx; + mkdir -p scripting/include plugins/disabled translations gamedata + runHook postConfigure + ''; + + buildPhase = '' + runHook preBuild + cd /build/scripting + [ -d ./include ] && SPCOMPFLAGS="$SPCOMPFLAGS -i ./include" + for plug in *.sp; do + spcomp -o "../plugins/disabled/''${plug%.sp}.smx" "$plug" + done + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + cd /build + find . -type d -empty -delete + odir=$out/share/addons/sourcemod + mkdir -p $odir + for d in scripting plugins translation gamedata; do + [ -d $d ] && cp -r $d $odir/$d + done + runHook postInstall + ''; +} // args // { + nativeBuildInputs = nativeBuildInputs ++ [ sourcemod ]; +}) -- cgit v1.2.3