Skip to content

Instantly share code, notes, and snippets.

@BrechtSerckx
Created January 1, 2021 20:34
Show Gist options
  • Save BrechtSerckx/e1db24b0780a0ee3e374fc13dec3634e to your computer and use it in GitHub Desktop.
Save BrechtSerckx/e1db24b0780a0ee3e374fc13dec3634e to your computer and use it in GitHub Desktop.
etlegacy
{ system ? builtins.currentSystem }:
let
pkgs = import <nixpkgs> { inherit system; };
callPackage = pkgs.lib.callPackageWith (pkgs // self);
self = with pkgs; {
etlegacy = callPackage_i686 ./etlegacy.nix {};
};
in self.etlegacy
{ stdenv
, lib
, makeWrapper
, fetchgit
, fetchFromGitHub
, fetchzip
, fetchurl
, cmake
, git
, glew
, SDL2
, zlib
, minizip
, libjpeg
, curl
, lua5_3
, libogg
, libtheora
, freetype
, libpng
, sqlite
, openal
, unzip
}:
let
version = "2.76";
pkgname = "etlegacy";
lua = lua5_3;
mirror = "https://mirror.etlegacy.com";
fetchAsset = {asset, sha256}: fetchurl
{ url = mirror + "/etmain/" + asset;
inherit sha256;
};
pak0 = fetchAsset
{ asset = "pak0.pk3";
sha256 = "712966b20e06523fe81419516500e499c86b2b4fec823856ddbd333fcb3d26e5";
};
pak1 = fetchAsset
{ asset = "pak1.pk3";
sha256 = "5610fd749024405b4425a7ce6397e58187b941d22092ef11d4844b427df53e5d";
};
pak2 = fetchAsset
{ asset = "pak2.pk3";
sha256 = "a48ab749a1a12ab4d9137286b1f23d642c29da59845b2bafc8f64e052cf06f3e";
};
binaries = builtins.fetchTarball {
url = "https://www.etlegacy.com/snapshot/file/122";
sha256 = "1wr0ghxq7xwbjlsvm6g0vmvssmk0hf7xncv3wcq8l4g66g57yw4x";
};
in stdenv.mkDerivation rec {
pname = pkgname;
inherit version;
src = fetchgit {
url= "https://github.com/etlegacy/etlegacy.git";
rev= "cf0ea440074b548c695553ba854a92f363666722";
sha256= "1mx9kqyl38418knx6i5q122v8072viig52bh2xfd68hxl644nvp6";
fetchSubmodules= false;
};
nativeBuildInputs = [ cmake git makeWrapper unzip ];
buildInputs = [
glew SDL2 zlib minizip libjpeg curl lua libogg libtheora freetype libpng sqlite openal
];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DCROSS_COMPILE32=0"
"-DBUILD_SERVER=0"
"-DBUILD_CLIENT=1"
"-DBUILD_MOD=0"
"-DBUILD_MOD_PK3=0"
"-DBUILD_PAK3_PK3=0"
"-DBUNDLED_JPEG=0"
"-DBUNDLED_LIBS=0"
"-DINSTALL_EXTRA=0"
"-DINSTALL_OMNIBOT=0"
"-DINSTALL_GEOIP=0"
"-DINSTALL_WOLFADMIN=0"
"-DFEATURE_AUTOUPDATE=0"
"-DINSTALL_DEFAULT_BASEDIR=."
"-DINSTALL_DEFAULT_BINDIR=."
"-DINSTALL_DEFAULT_MODDIR=."
];
postInstall = ''
ETMAIN=$out/etmain
mkdir -p $ETMAIN
ln -s ${pak0} $ETMAIN/pak0.pk3
ln -s ${pak1} $ETMAIN/pak1.pk3
ln -s ${pak2} $ETMAIN/pak2.pk3
LEGACY=$out/legacy
mkdir -p $LEGACY
ln -s ${binaries}/legacy/etl_bin_v${version}.pk3 $LEGACY/
ln -s ${binaries}/legacy/pak3_v${version}.pk3 $LEGACY/
ln -s ${binaries}/legacy/qagame.mp.i386.so $LEGACY/
'';
meta = with stdenv.lib; {
description = "ET: Legacy is an open source project based on the code of Wolfenstein: Enemy Territory which was released in 2010 under the terms of the GPLv3 license.";
homepage = https://etlegacy.com;
platforms = platforms.unix;
license = licenses.gpl3;
};
}
@ashleyghooper
Copy link

ashleyghooper commented Apr 29, 2023

FYI, there is now an etlegacy package available in nixpkgs-unstable for this, and it should also be in nixos-23.05 when that is released. By default it will install the 64-bit version, so if you want 32-bit, specify the package as pkgsi686Linux.etlegacy.

@garret
Copy link

garret commented Apr 30, 2023

@ashleyghooper thanks, I had noticed it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment