Skip to content

Instantly share code, notes, and snippets.

@chayleaf
Last active March 1, 2023 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chayleaf/a8ad389e520e58b885779e051450707e to your computer and use it in GitHub Desktop.
Save chayleaf/a8ad389e520e58b885779e051450707e to your computer and use it in GitHub Desktop.
Xash3D on NixOS
  1. (this isn't necessary if you're on a 32-bit x86 platform) Copy files from fwgs-hlsdk derivation to Half-Life dir (there shouldn't be any conflicting files). Example output with an AMD64 host platform:
fwgs-hlsdk-2023-02-22
└── valve
    ├── cl_dlls
    │   └── client_amd64.so
    └── dlls
        └── hl_amd64.so

In comparison, original Half-Life uses valve/cl_dlls/client.so and valve/dlls/hl.so, so in this case there aren't any conflicts.

  1. Run xash3d from the xash3d-fwgs derivation like this:
XASH3D_BASEDIR=~/.local/share/xash3d XASH3D_RODIR=/path/to/Half-Life xash3d
diff --git a/scripts/waifulib/zip.py b/scripts/waifulib/zip.py
index 6e903ba7..d47f1754 100644
--- a/scripts/waifulib/zip.py
+++ b/scripts/waifulib/zip.py
@@ -25,7 +25,11 @@ class ziparchive(Task.Task):
arcfile = src.path_from(self.relative_to)
Logs.debug('%s: %s <- %s as %s', self.__class__.__name__, outfile, infile, arcfile)
- zf.write(infile, arcfile)
+
+ arcfile = zipfile.ZipInfo(filename=arcfile, date_time=(1980, 1, 1, 0, 0, 0))
+
+ with open(infile, 'rb') as f:
+ zf.writestr(arcfile, f.read())
@TaskGen.feature('zip')
def create_zip_archive(self):
{ lib
, pkgs
, stdenv
, fetchFromGitHub
, gamedir ? "valve"
, enableGoldsourceSupport ? true
, enableVgui ? false
, enableVoicemgr ? false
, enableBugfixes ? false
, enableCrowbarIdleAnim ? false
}:
stdenv.mkDerivation {
pname = "fwgs-hlsdk";
version = "2023-03-01";
nativeBuildInputs = with pkgs; [cmake];
src = fetchFromGitHub {
owner = "FWGS";
repo = "hlsdk-portable";
rev = "d11f853464ee5d951e25ce9d0eea001780b92196";
sha256 = if enableVgui then "sha256-Qd+SUie+jlfxo6aefordYw665ZaNaR3TxufntfIaoCo=" else "sha256-WU+I+mmoyXvW1pvqJLddPaA8/tod3TtvqzVPYJRbGz4=";
fetchSubmodules = enableVgui;
};
cmakeFlags = let
optionals = lib.optionals;
optional = (cond: val: optionals cond [val]);
cmakeBool = (x: if x then "ON" else "OFF");
in [
"-DUSE_VGUI=${cmakeBool enableVgui}"
"-DGOLDSOURCE_SUPPORT=${cmakeBool enableGoldsourceSupport}"
"-DUSE_VOICEMGR=${cmakeBool enableVoicemgr}"
"-DBARNACLE_FIX_VISIBILITY=${cmakeBool enableBugfixes}"
"-DCROWBAR_DELAY_FIX=${cmakeBool enableBugfixes}"
"-DCROWBAR_FIX_RAPID_CROWBAR=${cmakeBool enableBugfixes}"
"-DGAUSS_OVERCHARGE_FIX=${cmakeBool enableBugfixes}"
"-DTRIPMINE_BEAM_DUPLICATION_FIX=${cmakeBool enableBugfixes}"
"-DHANDGRENADE_DEPLOY_FIX=${cmakeBool enableBugfixes}"
"-DWEAPONS_ANIMATION_TIMES_FIX=${cmakeBool enableBugfixes}"
"-DCROWBAR_IDLE_ANIM=${cmakeBool enableCrowbarIdleAnim}"
] ++ (optional (gamedir != "valve") "-DGAMEDIR=${gamedir}")
++ (optional stdenv.is64bit "-D64BIT=ON");
meta = with lib; {
description = "Portable Half-Life SDK. GoldSource and Xash3D. Crossplatform.";
homepage = "https://github.com/FWGS/hlsdk-portable";
license = with licenses; [ unfree ];
# maintainers = with maintainers; [ chayleaf ];
};
}
{ lib
, pkgs
, stdenv
, fetchFromGitHub
, dedicated ? false # dedicated server
, gamedir ? "valve"
, enableBsp2 ? false # bsp2 support (for quake)
, enableGles1 ? false # gles1 renderer (nanogl)
, enableGles2 ? false # gles2 renderer (glwes)
, enableGl4es ? false # gles2 renderer (gl4es)
, enableGl ? true # opengl renderer
, enableSoft ? true # soft renderer
, enableUtils ? false # mdldec
}:
stdenv.mkDerivation {
pname = "xash3d-fwgs";
version = "2023-03-01";
nativeBuildInputs = with pkgs; [python3 pkg-config makeWrapper];
buildInputs = with pkgs; [SDL2 libopus freetype fontconfig];
src = fetchFromGitHub {
owner = "FWGS";
repo = "xash3d-fwgs";
rev = "7e9d46689ca76d6bf1669ada6344fc724dd683cf";
sha256 = "sha256-rvONYm1Gz9PpK8KY6RIIJ82FtxGcWe/4YoT2eV4sCOc=";
fetchSubmodules = true;
};
patches = [ ./change-zip-date.patch ];
configurePhase = let
optionals = lib.optionals;
optional = (cond: val: optionals cond [val]);
flags = ["-8" "-P" "--prefix=/"]
++ (optional dedicated "-d")
++ (optionals (gamedir != "valve") ["--gamedir" gamedir])
++ (optional enableBsp2 "--enable-bsp2")
++ (optional enableGles1 "--enable-gles1")
++ (optional enableGles2 "--enable-gles2")
++ (optional enableGl4es "--enable-gl4es")
++ (optional (!enableGl) "--disable-gl")
++ (optional (!enableSoft) "--disable-soft")
++ (optional enableUtils "--enable-utils")
;
in ''
python3 ./waf configure -T release ${lib.strings.escapeShellArgs flags}
'';
buildPhase = ''
python3 ./waf build
'';
installPhase = ''
python3 ./waf install "--destdir=$out"
mkdir $out/bin
makeWrapper $out/lib/xash3d/xash3d $out/bin/xash3d --set XASH3D_EXTRAS_PAK1 $out/share/xash3d/valve/extras.pk3
'';
meta = with lib; {
description = "Xash3D FWGS engine";
homepage = "https://github.com/FWGS/xash3d-fwgs";
# this is a mess because of vendoring...
# maybe the correct thing to do use to simply use `[ unfree gpl3Plus ]` instead
license = with licenses; [ unfree gpl2Plus gpl3Plus lgpl3Plus mit bsd3 ];
# maintainers = with maintainers; [ chayleaf ];
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment