nillerusr / source-engine

Modified source engine (2017) developed by valve and leaked in 2020. Not for commercial purporses
Other
1.13k stars 175 forks source link

Wiki on Building: add Nix entry #266

Open TheBrainScrambler opened 1 year ago

TheBrainScrambler commented 1 year ago

The wiki isn't publicly editable, so I will put it here.

You need to put the following Nix expression in a file, say source-engine.nix

{ lib
, pkgs
, stdenv
, fetchFromGitHub
, game ? "hl2"
, python3, pkg-config, wafHook
, SDL2, freetype, fontconfig, zlib, bzip2, libjpeg, libpng, curl, openal, libopus
}:

stdenv.mkDerivation {
  pname = "source-engine";
  version = "2023-06-03";

  nativeBuildInputs = [ python3 pkg-config wafHook ];
  buildInputs = [ SDL2 freetype fontconfig zlib bzip2 libjpeg libpng curl openal libopus ];

  src = fetchFromGitHub {
    owner = "nillerusr";
    repo = "source-engine";
    rev = "0235b1ed4dcfdab52caaa98b40cfe15da15189c0";
    sha256 = "sha256-3RxkUxISXFbO36K/wuqN6t8VfHgEhGruF5qryXNweo4=";
    fetchSubmodules = true;
  };

  # --build-games actually builds a single game it seems
  wafConfigureFlags = [ "-8" "-T release" "--disable-warns" "--build-games ${game}" ];
}

You can change the game fron "hl2" to what you need. There is also "--disable-warns" in the flags because I couldn't build the engine without it. Also note that I pinned a commit from 2023-06-03, you might want to update that too.

To build run nix-build -E 'with import <nixpkgs> {}; callPackage ./source-engine.nix {}'