summary refs log tree commit diff
path: root/pkgs/games/soldat-unstable
diff options
context:
space:
mode:
authorsternenseemann <sternenseemann@systemli.org>2021-10-17 14:29:11 +0200
committersterni <sternenseemann@systemli.org>2021-11-13 18:49:45 +0100
commit4e50d99934fe6cd137738763ce045f4916c5e9ab (patch)
tree302c2fd1daf16faf5e84448476b5b16145b72524 /pkgs/games/soldat-unstable
parentd37d84bdcae7d248e8fe638a0289d1bf216adbd2 (diff)
downloadnixpkgs-4e50d99934fe6cd137738763ce045f4916c5e9ab.tar
nixpkgs-4e50d99934fe6cd137738763ce045f4916c5e9ab.tar.gz
nixpkgs-4e50d99934fe6cd137738763ce045f4916c5e9ab.tar.bz2
nixpkgs-4e50d99934fe6cd137738763ce045f4916c5e9ab.tar.lz
nixpkgs-4e50d99934fe6cd137738763ce045f4916c5e9ab.tar.xz
nixpkgs-4e50d99934fe6cd137738763ce045f4916c5e9ab.tar.zst
nixpkgs-4e50d99934fe6cd137738763ce045f4916c5e9ab.zip
soldat-unstable: build using CMake
This will be the build system going forward, so it seems sensible to
support it right away. There's no neat way to use the system
GameNetworkingSockets upstream yet, so we add a hack for now.

Proactively decrease platforms to Linux only since the CMake doesn't
quite use GNUInstallDirs on Darwin and Windows unfortunately.
Diffstat (limited to 'pkgs/games/soldat-unstable')
-rw-r--r--pkgs/games/soldat-unstable/default.nix58
-rw-r--r--pkgs/games/soldat-unstable/gamenetworkingsockets-no-external.patch14
2 files changed, 33 insertions, 39 deletions
diff --git a/pkgs/games/soldat-unstable/default.nix b/pkgs/games/soldat-unstable/default.nix
index 69fc90dff84..b3ae3b58cfe 100644
--- a/pkgs/games/soldat-unstable/default.nix
+++ b/pkgs/games/soldat-unstable/default.nix
@@ -1,6 +1,6 @@
 { lib, stdenv, fetchFromGitHub, fpc, zip, makeWrapper
 , SDL2, freetype, physfs, openal, gamenetworkingsockets
-, xorg, autoPatchelfHook
+, xorg, autoPatchelfHook, cmake
 }:
 
 let
@@ -49,45 +49,27 @@ stdenv.mkDerivation rec {
     sha256 = "0r39d1394q7kabsgq6vpdlzwsajxafsg23i0r273nggfvs3m805z";
   };
 
-  nativeBuildInputs = [ fpc makeWrapper autoPatchelfHook ];
+  patches = [
+    # Don't build GameNetworkingSockets as an ExternalProject,
+    # see https://github.com/Soldat/soldat/issues/73
+    ./gamenetworkingsockets-no-external.patch
+  ];
 
-  buildInputs = [ SDL2 freetype physfs openal gamenetworkingsockets ];
-  runtimeDependencies = [ xorg.libX11 ];
-
-  buildPhase = ''
-    runHook preBuild
-
-    mkdir -p client/build server/build
-
-    # build .so from stb headers
-    pushd client/libs/stb
-    make
-    popd
-
-    # build client
-    pushd client
-    make mode=release
-    popd
+  nativeBuildInputs = [ fpc makeWrapper autoPatchelfHook cmake ];
 
-    # build server
-    pushd server
-    make mode=release
-    popd
+  cmakeFlags = [
+    "-DADD_ASSETS=OFF" # We provide base's smods via nix
+  ];
 
-    runHook postBuild
-  '';
-
-  installPhase = ''
-    runHook preInstall
-
-    install -Dm644 client/libs/stb/libstb.so -t $out/lib
-    install -Dm755 client/build/soldat_* $out/bin/soldat
-    install -Dm755 server/build/soldatserver_* $out/bin/soldatserver
+  buildInputs = [ SDL2 freetype physfs openal gamenetworkingsockets ];
+  # TODO(@sternenseemann): set proper rpath via cmake, so we don't need autoPatchelfHook
+  runtimeDependencies = [ xorg.libX11 ];
 
-    # make sure soldat{,server} find their game archive,
-    # let them write their state and configuration files
-    # to $XDG_CONFIG_HOME/soldat/soldat{,server} unless
-    # the user specifies otherwise.
+  # make sure soldat{,server} find their game archive,
+  # let them write their state and configuration files
+  # to $XDG_CONFIG_HOME/soldat/soldat{,server} unless
+  # the user specifies otherwise.
+  postInstall = ''
     for p in $out/bin/soldatserver $out/bin/soldat; do
       configDir="\''${XDG_CONFIG_HOME:-\$HOME/.config}/soldat/$(basename "$p")"
 
@@ -97,8 +79,6 @@ stdenv.mkDerivation rec {
         --add-flags "-fs_userpath \"$configDir\"" \
         --add-flags "-fs_basepath \"${base}/share/soldat\""
     done
-
-    runHook postInstall
   '';
 
   meta = with lib; {
@@ -106,7 +86,7 @@ stdenv.mkDerivation rec {
     license = [ licenses.mit base.meta.license ];
     inherit (src.meta) homepage;
     maintainers = [ maintainers.sternenseemann ];
-    platforms = platforms.x86_64 ++ platforms.i686;
+    platforms = [ "x86_64-linux" "i686-linux" ];
     # portability currently mainly limited by fpc
     # in nixpkgs which doesn't work on darwin,
     # aarch64 and arm support should be possible:
diff --git a/pkgs/games/soldat-unstable/gamenetworkingsockets-no-external.patch b/pkgs/games/soldat-unstable/gamenetworkingsockets-no-external.patch
new file mode 100644
index 00000000000..629ca6c6751
--- /dev/null
+++ b/pkgs/games/soldat-unstable/gamenetworkingsockets-no-external.patch
@@ -0,0 +1,14 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 1084048..1ea4c84 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -143,7 +143,8 @@ if(BUILD_CLIENT OR BUILD_SERVER)
+     file(WRITE ${PROJECT_BINARY_DIR}/bin/steam_appid.txt "638490")
+   else()
+     # GameNetworkingSockets
+-    add_subdirectory(shared/libs/GameNetworkingSockets)
++    # add_subdirectory(shared/libs/GameNetworkingSockets)
++    find_package(GameNetworkingSockets REQUIRED)
+   endif()
+ endif()
+