-
-
Save ashleyghooper/740f1c90cf69e6059b6fe0f650a424a6 to your computer and use it in GitHub Desktop.
etlegacy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ system ? builtins.currentSystem }: | |
let | |
pkgs = import <nixpkgs> { inherit system; }; | |
callPackage = pkgs.lib.callPackageWith (pkgs // self); | |
self = with pkgs; { | |
etlegacy-x86 = callPackage_i686 ./etlegacy-x86.nix { usePrecompiledModLibs = true; }; | |
etlegacy-x86_64 = callPackage ./etlegacy-x86_64.nix { usePrecompiledModLibs = true; }; | |
}; | |
in self.etlegacy-x86 # or self.etlegacy-x86_64 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ stdenv | |
, lib | |
# Whether to use the mod libs from the binary distributions | |
# built by the ET Legacy project's CI pipeline. | |
, usePrecompiledModLibs ? true | |
, makeWrapper | |
, fetchgit | |
, fetchFromGitHub | |
, fetchzip | |
, fetchurl | |
, runCommand | |
, cmake | |
, git | |
, glew | |
, SDL2 | |
, zlib | |
, minizip | |
, libjpeg | |
, curl | |
, lua5_4 | |
, libogg | |
, libtheora | |
, freetype | |
, libpng | |
, sqlite | |
, openal | |
, unzip | |
, cjson | |
}: | |
let | |
version = "2.81.1"; | |
pkgname = "etlegacy-x86"; | |
lua = lua5_4; | |
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"; | |
}; | |
options = if usePrecompiledModLibs then { | |
binaries = builtins.fetchTarball { | |
url = "https://www.etlegacy.com/download/file/554"; # ET Legacy 2.81.1 Linux 32-bit | |
sha256 = "0g1jcqshqzbjwn3bb7ihbw1flvpj8ssz3w73q87021qmg9z8h8hy"; | |
}; | |
cmakeFlagsExtra = [ | |
"-DBUILD_MOD=0" | |
"-DBUILD_MOD_PK3=0" | |
]; | |
} | |
else { | |
cmakeFlagsExtra = []; | |
}; | |
gamedir = stdenv.mkDerivation rec { | |
pname = pkgname; | |
inherit version; | |
src = fetchgit { | |
url= "https://github.com/etlegacy/etlegacy.git"; | |
rev= "v" + version; | |
sha256 = "sha256-CGXtc51vaId/SHbD34ZeT0gPsrl7p2DEw/Kp+GBZIaA="; # 2.81.1 | |
fetchSubmodules= false; | |
}; | |
nativeBuildInputs = [ cmake git makeWrapper unzip cjson ]; | |
buildInputs = [ | |
glew SDL2 zlib minizip libjpeg curl lua libogg libtheora freetype libpng sqlite openal | |
]; | |
cmakeFlagsBase = [ | |
"-DCMAKE_BUILD_TYPE=Release" | |
"-DCROSS_COMPILE32=1" | |
"-DBUILD_SERVER=0" | |
"-DBUILD_CLIENT=1" | |
"-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=." | |
]; | |
cmakeFlags = cmakeFlagsBase ++ options.cmakeFlagsExtra; | |
postInstallBase = '' | |
ETMAIN=$out/etmain | |
mkdir -p $ETMAIN | |
ln -s ${pak0} $ETMAIN/pak0.pk3 | |
ln -s ${pak1} $ETMAIN/pak1.pk3 | |
ln -s ${pak2} $ETMAIN/pak2.pk3 | |
''; | |
postInstallExtra = if usePrecompiledModLibs then '' | |
LEGACY=$out/legacy | |
mkdir -p $LEGACY | |
ln -s ${options.binaries}/legacy/legacy_v${version}.pk3 $LEGACY/ | |
ln -s ${options.binaries}/legacy/qagame.mp.i386.so $LEGACY/ | |
'' else ""; | |
postInstall = postInstallBase + postInstallExtra; | |
meta = with 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; | |
}; | |
}; | |
in runCommand "etlegacy-x86" { buildInputs = [ makeWrapper ]; } '' | |
BIN=$out/bin | |
mkdir -p $BIN | |
# In successive releases, executable changed from etl.i386 to etl.x86 and back | |
if [[ -x ${gamedir}/etl.i386 ]]; then | |
EXE=etl.i386 | |
elif [[ -x ${gamedir}/etl.x86 ]]; then | |
EXE=etl.x86 | |
else | |
echo "Unable to determine executable" | |
exit 1 | |
fi | |
makeWrapper ${gamedir}/$EXE $BIN/$EXE --chdir ${gamedir} | |
cp -r ${gamedir}/share $out/share | |
'' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ stdenv | |
, lib | |
# Whether to use the mod libs from the binary distributions | |
# built by the ET Legacy project's CI pipeline. | |
, usePrecompiledModLibs ? true | |
, makeWrapper | |
, fetchgit | |
, fetchFromGitHub | |
, fetchzip | |
, fetchurl | |
, runCommand | |
, cmake | |
, git | |
, glew | |
, SDL2 | |
, zlib | |
, minizip | |
, libjpeg | |
, curl | |
, lua5_4 | |
, libogg | |
, libtheora | |
, freetype | |
, libpng | |
, sqlite | |
, openal | |
, unzip | |
, cjson | |
}: | |
let | |
pkgname = "etlegacy-x86_64"; | |
version = "2.81.1"; | |
lua = lua5_4; | |
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"; | |
}; | |
options = if usePrecompiledModLibs then { | |
binaries = builtins.fetchTarball { | |
url = "https://www.etlegacy.com/download/file/553"; # ET Legacy 2.81.1 Linux x64 | |
sha256 = "0977kv1yr1a6571xpkk9706jwz1zv9fns6762y4axxrlab576cij"; | |
}; | |
cmakeFlagsExtra = [ | |
"-DBUILD_MOD=0" | |
"-DBUILD_MOD_PK3=0" | |
]; | |
} | |
else { | |
cmakeFlagsExtra = []; | |
}; | |
gamedir = stdenv.mkDerivation rec { | |
pname = pkgname; | |
inherit version; | |
src = fetchgit { | |
url = "https://github.com/etlegacy/etlegacy.git"; | |
rev = "refs/tags/v" + version; | |
sha256 = "sha256-CGXtc51vaId/SHbD34ZeT0gPsrl7p2DEw/Kp+GBZIaA="; # 2.81.1 | |
fetchSubmodules= false; | |
}; | |
nativeBuildInputs = [ cmake git makeWrapper unzip cjson ]; | |
buildInputs = [ | |
glew SDL2 zlib minizip libjpeg curl lua libogg libtheora freetype libpng sqlite openal | |
]; | |
cmakeFlagsBase = [ | |
"-DCMAKE_BUILD_TYPE=Release" | |
"-DCROSS_COMPILE32=0" | |
"-DBUILD_SERVER=0" | |
"-DBUILD_CLIENT=1" | |
"-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=." | |
]; | |
cmakeFlags = cmakeFlagsBase ++ options.cmakeFlagsExtra; | |
postInstallBase = '' | |
ETMAIN=$out/etmain | |
mkdir -p $ETMAIN | |
ln -s ${pak0} $ETMAIN/pak0.pk3 | |
ln -s ${pak1} $ETMAIN/pak1.pk3 | |
ln -s ${pak2} $ETMAIN/pak2.pk3 | |
''; | |
postInstallExtra = if usePrecompiledModLibs then '' | |
LEGACY=$out/legacy | |
mkdir -p $LEGACY | |
ln -s ${options.binaries}/legacy/legacy_v${version}.pk3 $LEGACY/ | |
ln -s ${options.binaries}/legacy/qagame.mp.x86_64.so $LEGACY/ | |
'' else ""; | |
postInstall = postInstallBase + postInstallExtra; | |
meta = with 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; | |
}; | |
}; | |
in runCommand "etlegacy-x86_64" { buildInputs = [ makeWrapper ]; } '' | |
BIN=$out/bin | |
mkdir -p $BIN | |
makeWrapper ${gamedir}/etl.x86_64 $BIN/etl.x86_64 --chdir ${gamedir} | |
cp -r ${gamedir}/share $out/share | |
'' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example that can be used in a NixOS system configuration | |
{ pkgs, config, ... }: | |
{ | |
environment.systemPackages = with pkgs; [ | |
dosbox | |
(pkgs.callPackage_i686 ../pkgs/etlegacy-x86 { usePrecompiledModLibs = true; }) | |
(pkgs.callPackage ../pkgs/etlegacy-x86_64 { usePrecompiledModLibs = true; }) | |
freedroid | |
fuse-emulator | |
mame | |
]; | |
hardware.opengl.driSupport32Bit = true; | |
# programs.steam.enable = true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've finally got a working package and created a pull request to get it merged into nixpkgs, so soon it should be as easy to install as any other package.
NixOS/nixpkgs#222633