-
-
Save BrechtSerckx/e1db24b0780a0ee3e374fc13dec3634e to your computer and use it in GitHub Desktop.
{ 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; | |
}; | |
} |
For anybody reading, I managed to get version 2.76 working by simply changing this URL:
48c48
< url = "https://www.etlegacy.com/snapshot/file/122";
---
> url = "https://www.etlegacy.com/download/file/122";
@ashleyghooper Are you on nixos-unstable? How do you build the derivation?
I'm on nixos-21.05. To build it, I created a directory and inside it created the files as per Brecht's example, changing the URL as per my previous comment, then I simply ran from that directory:
nix-build
Once it had downloaded files and compiled, I changed directory to the result
directory, and ran ./etl
. I haven't got as far as installing the derivation yet, but that should just be a case of copying it to somewhere in my /etc/nixos/
tree and including it.
I also needed this in my configuration.nix
:
hardware.opengl.driSupport32Bit = true;
Here's what I currently have in case it helps anybody (it supports several versions of etlegacy - switch by commenting/uncommenting references as appropriate):
{ 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.79.0";
version = "2.80.2";
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_2_76 = builtins.fetchTarball {
url = "https://www.etlegacy.com/download/file/122"; # Wolf ET 2.76
sha256 = "1wr0ghxq7xwbjlsvm6g0vmvssmk0hf7xncv3wcq8l4g66g57yw4x";
};
binaries_2_79_0 = builtins.fetchTarball {
url = "https://www.etlegacy.com/download/file/346"; # ET Legacy 2.79
sha256 = "1s3mfxha5wda18mdqv288jrigf0q2jir1h6d5brxnpi821h4ryiz";
};
binaries_2_80_2 = builtins.fetchTarball {
url = "https://www.etlegacy.com/download/file/410"; # ET Legacy 2.80.2
sha256 = "0bjhp0d4hwh55f0phzx490p5nrgryn8w20d7viphsyyhjxcbn6q8";
};
in stdenv.mkDerivation rec {
pname = pkgname;
inherit version;
src = fetchgit {
url= "https://github.com/etlegacy/etlegacy.git";
rev= "v" + version;
# sha256 = "sha256-k3eqWe5bR1mTQJBdJ57JfqrR3kqqGnxD0tfdfF1q/aU="; # 2.76
# sha256 = "sha256-U3Jn2ANAdNyK0ViXkYemK5bX5wPRQ8/xOhiS/IsLNrM="; # 2.79
sha256 = "sha256-k3eqWe5bR1mTQJBdJ57JfqrR3kqqGnxD0tfdfF1q/aU="; # 2.80.2
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
# 2.76
# ln -s ${binaries_2_76}/legacy/etl_bin_v${version}.pk3 $LEGACY/
# ln -s ${binaries_2_76}/legacy/pak3_v${version}.pk3 $LEGACY/
# ln -s ${binaries_2_76}/legacy/qagame.mp.i386.so $LEGACY/
# 2.79.0
# ln -s ${binaries_2_79_0}/legacy/legacy_v${version}.pk3 $LEGACY/
# ln -s ${binaries_2_79_0}/legacy/qagame.mp.i386.so $LEGACY/
# 2.80.2
ln -s ${binaries_2_80_2}/legacy/legacy_v${version}.pk3 $LEGACY/
ln -s ${binaries_2_80_2}/legacy/qagame.mp.i386.so $LEGACY/
'';
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;
};
}
...which I reference as below:
{ pkgs, config, ... }:
{
environment.systemPackages = with pkgs; [
(pkgs.callPackage_i686 ../pkgs/etlegacy { })
];
hardware.opengl.driSupport32Bit = true;
}
@ashleyghooper I am still quite noob with nixos. May I ask for a guide/code on how to get the 64 bit version of the latest etlegacy?
@ashleyghooper I am still quite noob with nixos. May I ask for a guide/code on how to get the 64 bit version of the latest etlegacy?
@garret, try my gist here:
https://gist.github.com/ashleyghooper/740f1c90cf69e6059b6fe0f650a424a6
@ashleyghooper Thank you very much!
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
.
@ashleyghooper thanks, I had noticed it!
Hi @BrechtSerckx , thanks for putting this together. Unfortunately it doesn't work for me with the current versions available on the etlegacy site - it fails with this error, because the snapshot referenced in
etlegacy.nix
is no longer available:Although I've been using NixOS for a few years now, I'm still a bit of a noob and haven't really got to grips with derivations, but I have attempted to update for the current version 2.79:
Any help would be greatly appreciated.