/* 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/''${plug%.sp}.smx" "$plug" done runHook postBuild ''; installPhase = '' runHook preInstall cd /build for plug in plugins/*.smx; do mv $plug plugins/disabled/ done find . -type d -empty -delete odir=$out/share/addons/sourcemod mkdir -p $odir for d in scripting plugins translations gamedata; do [ -d $d ] && cp -r $d $odir/$d done runHook postInstall ''; } // args // { nativeBuildInputs = nativeBuildInputs ++ [ sourcemod ]; })