diff --git a/flake.nix b/flake.nix index 6806e63..fad57cc 100644 --- a/flake.nix +++ b/flake.nix @@ -39,7 +39,7 @@ }; perSystem = pkgs: { - sourcemods = pkgs.lib.mapAttrs (name: sdk: pkgs.sourcemod.override {sdks = {${name} = sdk;};}) pkgs.hl2sdk; + sourcemods = pkgs.lib.mapAttrs (name: sdk: pkgs.sourcemod-builder {${name} = sdk;}) pkgs.hl2sdk; metamods = pkgs.lib.mapAttrs (name: sdk: pkgs.metamod-source-builder {${name} = sdk;}) pkgs.hl2sdk; hl2sdk = pkgs.hl2sdk; steam-depots = pkgs.steam-depots; @@ -58,8 +58,17 @@ ] // { test = pkgs: - pkgs.srcds-tf2.withConfig { - hostname = "Spire Server"; + (pkgs.srcds-tf2.withConfig + { + hostname = "Spire Server"; + }).withSourcemod {}; + testScript = pkgs: + pkgs.buildSourcePawnScript { + name = "test"; + src = pkgs.fetchurl { + url = "https://codeberg.org/spire/nocheats/raw/commit/5e0e21c241fdf8907d83d9bcf3cce37711b83d14/plugin/nocheats.sp"; + sha256 = "sha256-Z3RJhuc9c8YQTo9gnLTBrqL4JpADZgDttrJVyE/MWdM="; + }; }; }; diff --git a/nix/sourcemod/hl2sdk.nix b/nix/sourcemod/hl2sdk.nix index b333adc..f3b4a1c 100644 --- a/nix/sourcemod/hl2sdk.nix +++ b/nix/sourcemod/hl2sdk.nix @@ -4,8 +4,7 @@ nix-update-script, lib, }: let - inherit (builtins) mapAttrs; - inherit (lib) optionals importJSON; + inherit (lib) importJSON mapAttrs; revisions = importJSON ./hl2sdks.json; fetchRev = { rev, diff --git a/nix/sourcemod/overlay.nix b/nix/sourcemod/overlay.nix index f53992b..9383ed9 100644 --- a/nix/sourcemod/overlay.nix +++ b/nix/sourcemod/overlay.nix @@ -6,7 +6,8 @@ final: prev: { ambuild = final.python3Packages.callPackage ./ambuild.nix {}; metamod-source = final.callPackage ./metamod-source.nix {} {}; metamod-source-builder = final.callPackage ./metamod-source.nix {}; - sourcemod = final.callPackage ./sourcemod.nix {}; + sourcemod = final.callPackage ./sourcemod.nix {} {}; + sourcemod-builder = final.callPackage ./sourcemod.nix {}; sourcepawn = final.callPackage ./sourcepawn.nix {}; sourcemod-includes = final.callPackage ./includes/sourcemod-includes.nix {}; buildSourcePawnScript = final.callPackage ./build-sourcepawn-script.nix {}; diff --git a/nix/sourcemod/sourcemod.nix b/nix/sourcemod/sourcemod.nix index e203181..e04fb3d 100644 --- a/nix/sourcemod/sourcemod.nix +++ b/nix/sourcemod/sourcemod.nix @@ -8,8 +8,7 @@ writeShellScriptBin, zlib, writeScript, - sdks ? {}, -}: let +}: sdks: let inherit (builtins) concatStringsSep attrNames attrValues; inherit (lib) optionals; combinedSdks = symlinkJoin { diff --git a/nix/srcds/default.nix b/nix/srcds/default.nix index 56d5508..8fa2bf5 100644 --- a/nix/srcds/default.nix +++ b/nix/srcds/default.nix @@ -11,8 +11,13 @@ steamworks-sdk-redist, system, callPackage, - srcds-tf2, depots, + sourcemod-builder, + metamod-source-builder, + gamedir, + hl2sdk, + sdk, + writeTextDir, }: let inherit (lib) importJSON map toString elem last replaceStrings naturalSort filter any; depotInputs = importJSON ./depots.json; @@ -76,28 +81,36 @@ }; in final; - makeWithSourcemod = base: config: let - configFile = callPackage ./cfg.nix { - name = "server.cfg"; - cfg = config; + makeWithSourcemod = base: {}: let + sdks = { + ${sdk} = hl2sdk.${sdk}; }; + metaModSdk = metamod-source-builder sdks; + sourceModSdk = sourcemod-builder sdks; final = symlinkJoin { name = "srcds-tf2-src"; - paths = [base configFile]; + paths = [base metaModSdk sourceModSdk]; passthru = makeWiths final; + postBuild = '' + mv $out/share/cfg/* $out/tf/cfg/ + mv $out/share/addons $out/tf/addons + + rm -r $out/include $out/share + ''; }; in final; makeWiths = base: { withConfig = makeWithConfig base; + withSourcemod = makeWithSourcemod base; }; mainProgram = if system == "x86_64-linux" then "srcds_run_64" else "srcds_run"; -in - stdenvNoCC.mkDerivation (finalAttrs: { + + final = stdenvNoCC.mkDerivation (finalAttrs: { pname = "srcds-tf2"; version = timeToVersion time; inherit src; @@ -129,7 +142,7 @@ in runHook postInstall ''; - passthru = makeWiths srcds-tf2; + passthru = makeWiths final; meta = with lib; { inherit mainProgram; @@ -142,4 +155,6 @@ in license = licenses.unfree; platforms = ["x86_64-linux" "i686-linux"]; }; - }) + }); +in + final diff --git a/nix/srcds/overlay.nix b/nix/srcds/overlay.nix index fd2a10b..84183c6 100644 --- a/nix/srcds/overlay.nix +++ b/nix/srcds/overlay.nix @@ -13,6 +13,8 @@ in { depot_id = 232250; } ]; + gamedir = "tf"; + sdk = "tf2"; }; steam-depots = listToAttrs (map (depot: { name = "steam-depot-${toString depot.app_id}-${toString depot.depot_id}";