ioquake3: enable build on darwin and add high-res mods (#388021)

This commit is contained in:
Pol Dellaiera
2025-06-14 19:14:10 +02:00
committed by GitHub
7 changed files with 269 additions and 43 deletions
+45 -9
View File
@@ -19,9 +19,10 @@
freetype,
mumble,
unstableGitUpdater,
bc,
}:
stdenv.mkDerivation {
stdenv.mkDerivation (finalAttrs: {
pname = "ioquake3";
version = "0-unstable-2025-05-15";
@@ -37,6 +38,7 @@ stdenv.mkDerivation {
makeBinaryWrapper
pkg-config
which
bc
];
buildInputs = [
@@ -59,23 +61,57 @@ stdenv.mkDerivation {
cp ${./Makefile.local} ./Makefile.local
'';
preBuild = lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace Makefile \
--replace-fail \
"-I/Library/Frameworks/SDL2.framework/Headers" \
"-I${lib.getDev SDL2}/include/SDL2" \
--replace-fail \
"CLIENT_LIBS += -framework SDL2" \
"CLIENT_LIBS += -L${lib.getLib SDL2}/lib -lSDL2" \
--replace-fail \
"RENDERER_LIBS += -framework SDL2" \
"RENDERER_LIBS += -L${lib.getLib SDL2}/lib -lSDL2" \
--replace-fail \
"-I/System/Library/Frameworks/OpenAL.framework/Headers" \
"-I${lib.getDev openal}/include/AL" \
--replace-fail \
"CLIENT_LIBS += -framework OpenAL" \
"CLIENT_LIBS += -L${lib.getLib openal}/lib -lopenal" \
--replace-fail \
"TOOLS_CC = gcc" \
"TOOLS_CC = clang"
'';
postBuild = lib.optionalString stdenv.hostPlatform.isDarwin ''
echo "Building Application Bundle for Darwin / macOS"
# The following script works without extensive patching (see preBuild), as the regular buil already
# built all the c code and libraries.
./make-macosx.sh ${stdenv.hostPlatform.darwinArch}
'';
installTargets = [ "copyfiles" ];
installFlags = [ "COPYDIR=$(out)/share/ioquake3" ];
postInstall = ''
install -Dm644 misc/quake3.svg $out/share/icons/hicolor/scalable/apps/ioquake3.svg
postInstall =
''
install -Dm644 misc/quake3.svg $out/share/icons/hicolor/scalable/apps/ioquake3.svg
makeWrapper $out/share/ioquake3/ioquake3.* $out/bin/ioquake3
makeWrapper $out/share/ioquake3/ioq3ded.* $out/bin/ioq3ded
'';
makeWrapper $out/share/ioquake3/ioquake3.* $out/bin/ioquake3
makeWrapper $out/share/ioquake3/ioq3ded.* $out/bin/ioq3ded
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir -p $out/Applications
mv build/release-darwin-${stdenv.hostPlatform.darwinArch}/ioquake3.app $out/Applications/
'';
desktopItems = [
(makeDesktopItem {
name = "IOQuake3";
exec = "ioquake3";
icon = "ioquake3";
comment = "A fast-paced 3D first-person shooter, a community effort to continue supporting/developing id's Quake III Arena";
comment = finalAttrs.meta.description;
desktopName = "ioquake3";
categories = [
"Game"
@@ -96,6 +132,6 @@ stdenv.mkDerivation {
drupol
rvolosatovs
];
platforms = lib.platforms.linux;
platforms = lib.platforms.unix;
};
}
})
+65
View File
@@ -0,0 +1,65 @@
{
lib,
stdenv,
fetchzip,
requireFile,
}:
let
version = "1.32c";
in
stdenv.mkDerivation (finalAttrs: {
pname = "quake3arenadata";
inherit version;
src = requireFile rec {
name = "pak0.pk3";
hash = "sha256-fOizkQYgzVCgnk8RAPQm6MYYD2iJXVifgOa9la9UvK4=";
message = ''
Quake 3 Arena requires the original ${name} file, from any legal source of the game.
This could be an old CD-ROM you have lying around or you can try to buy the game.
To my knowledge the Steam Quake-Collection-Package, is about the last legal way to get it.
Please note, there are plenty of versions of this file online like:
- https://github.com/nrempel/q3-server/raw/master/baseq3/pak0.pk3
- https://archive.org/details/quake-3-arena
However, none of these have the blessing of ID-Software and thus do not qualify.
Once you download a version or checked your old CD-ROM, locate the ${name} file
inside the baseq3 folder and then run the following command on it:
nix-prefetch-url file:///path/to/baseq3/${name}
'';
};
buildCommand = ''
mkdir -p $out/baseq3
echo 'wwwwwwwwwwwwwwww' > $out/baseq3/q3key
ln -s $src $out/baseq3/pak0.pk3
'';
preferLocalBuild = true;
meta = {
description = "Quake 3 Arena content";
longDescription = ''
Quake III Arena and it's demo don't offer current wide screen resolutions in the menu.
To switch to such a resolution, you will have to enter something like this in the quake console (invoke with ~ by default)
r_mode -1; r_customwidth 2560; r_customheight 1440; r_fullscreen 1; vid_restart
Or call the quake commandline with these parameters
$ quake3 +set r_mode -1 +set r_customwidth 2560 +set r_customheight 1440 +set r_fullscreen 1
'';
homepage = "https://www.idsoftware.com/";
license = lib.licenses.unfreeRedistributable;
platforms = lib.platforms.all;
maintainers = with lib.maintainers; [ abbradar ];
};
})
+13 -1
View File
@@ -26,7 +26,19 @@ stdenv.mkDerivation {
preferLocalBuild = true;
meta = with lib; {
description = "Quake 3 Arena demo content";
description = "Demo of Quake 3 Arena, a classic first-person shooter";
longDescription = ''
Quake III Arena and it's demo don't offer current wide screen resolutions in the menu.
To switch to such a resolution, you will have to enter something like this in the quake console (invoke with ~ by default)
r_mode -1; r_customwidth 2560; r_customheight 1440; r_fullscreen 1; vid_restart
Or call the quake commandline with these parameters
$ quake3 +set r_mode -1 +set r_customwidth 2560 +set r_customheight 1440 +set r_fullscreen 1
'';
homepage = "https://www.idsoftware.com/";
license = licenses.unfreeRedistributable;
platforms = platforms.all;
maintainers = with maintainers; [ abbradar ];
+47 -3
View File
@@ -2,11 +2,18 @@
stdenv,
lib,
fetchzip,
fetchurl,
fetchFromGitHub,
libarchive,
}:
stdenv.mkDerivation {
stdenv.mkDerivation (finalAttrs: {
pname = "quake3hires";
version = "2020-01-20"; # Unknown version, used the date of web.archive.org capture.
version = "unstable-2020-01-20"; # Unknown version, used the date of web.archive.org capture.
nativeBuildInputs = [
libarchive
];
src = fetchzip {
url = "https://web.archive.org/web/20200120024216/http://ioquake3.org/files/xcsv_hires.zip";
@@ -14,9 +21,46 @@ stdenv.mkDerivation {
stripRoot = false;
};
# https://www.moddb.com/mods/high-quality-quake
# TODO check if that file needs renaming to something that starts with z_* so it actually overrides anything in pak0.pk3
extra-pack-resolution = fetchurl {
url = "https://web.archive.org/web/20250310093216/https://fmt3.dl.dbolical.com/dl/2018/11/06/q3a-hqq-v37.zip?st=0XzNnNvOYWrJAi_6AB3mKw==&e=1741602736";
hash = "sha256-0nAXkrf4ahlct75TgO18PjuT9IkH8fpDhtTflJfPpPM=";
};
# https://www.moddb.com/mods/cz45modbundle/addons/cz45-q3a-weapon-model-remake-v10
# https://www.moddb.com/downloads/mirror/255463/130/9de70b5dc7ebb1baa44acf91458b04f9/
# this is only part of the mod, only the weapons skins
# url = "https://github.com/diegoulloao/ioquake3-mac-install/raw/master/extras/hd-weapons.pk3";
hd-weapons = fetchurl {
name = "czq3hdweaprem_v10.zip";
url = "https://web.archive.org/web/20250310101737/https://fmt1.dl.dbolical.com/dl/2023/08/13/czq3hdweaprem_v10.zip?st=XBoRCpVmvTYtc60xxi36VQ==&e=1741605457";
hash = "sha256-pL7MsEFsKJV+a+z45Ns16SPdQB3i2D6T3x7tBqWtm1s=";
};
# According to the @diegoulloao (see https://github.com/diegoulloao/ioquake3-mac-install/issues/23#issuecomment-2817031996)
# quake3-live-sounds.pk3 is likely a custom repack from https://www.moddb.com/addons/quake-live-announcers-pack
# zpack-weapons.pk3 is an amalgamation of multiple mods, where he can't recall which ones he used exactly.
# It still makes him the authorative source for these file.
ioquake3_mac = fetchFromGitHub {
owner = "diegoulloao";
repo = "ioquake3-mac-install";
rev = "3a767ff0131742ec517fd5f13ddca16dee91927d";
hash = "sha256-uY3pybCnQ7lZatP3s9AiT779/4xj8N3R4qx8V6991aM=";
};
buildCommand = ''
mkdir -p $out/baseq3
install -Dm444 $src/xcsv_bq3hi-res.pk3 $out/baseq3/xcsv_bq3hi-res.pk3
install -Dm444 ${finalAttrs.extra-pack-resolution} $out/baseq3/pak9hqq37test20181106.pk3
bsdunzip ${finalAttrs.hd-weapons}
install -Dm444 zzczhdwr1.pk3 $out/baseq3/zzczhdwr1.pk3
# https://github.com/diegoulloao/ioquake3-mac-install takes only the first file, following his lead for now
# install -Dm444 zzczhdwr2.pk3 $out/baseq3/zzczhdwr2.pk3
# install -Dm444 zzczhdwr3.pk3 $out/baseq3/zzczhdwr3.pk3
install -Dm444 ${finalAttrs.ioquake3_mac}/extras/quake3-live-sounds.pk3 $out/baseq3/quake3-live-sounds.pk3
install -Dm444 ${finalAttrs.ioquake3_mac}/extras/zpack-weapons.pk3 $out/baseq3/zpack-weapons.pk3
'';
preferLocalBuild = true;
@@ -27,4 +71,4 @@ stdenv.mkDerivation {
platforms = platforms.all;
maintainers = with maintainers; [ rvolosatovs ];
};
}
})
+46
View File
@@ -0,0 +1,46 @@
callPackage: rec {
# main entry point to create a runnable quake3
quake3wrapper = callPackage ./wrapper { };
# data files
quake3arenadata = callPackage ./content/arena.nix { };
quake3demodata = callPackage ./content/demo.nix { };
quake3pointrelease = callPackage ./content/pointrelease.nix { };
quake3hires = callPackage ./content/hires.nix { };
# runnable quakes with different configurations / mods
quake3arena = quake3wrapper {
pname = "quake3";
paks = [
quake3arenadata
quake3pointrelease
];
};
quake3arena-hires = quake3wrapper {
pname = "quake3";
paks = [
quake3arenadata
quake3pointrelease
quake3hires
];
};
quake3demo = quake3wrapper {
pname = "quake3-demo";
paks = [
quake3demodata
quake3pointrelease
];
};
quake3demo-hires = quake3wrapper {
pname = "quake3-demo";
paks = [
quake3demodata
quake3pointrelease
quake3hires
];
};
}
+42 -14
View File
@@ -9,7 +9,8 @@
{
paks,
name ? (lib.head paks).name,
pname ? (lib.head paks).pname,
version ? (lib.head paks).version,
description ? "",
}:
@@ -25,25 +26,52 @@ let
in
stdenv.mkDerivation {
name = "${name}-${ioquake3.name}";
pname = "${pname}-${ioquake3.name}";
inherit version;
nativeBuildInputs = [ makeWrapper ];
buildCommand = ''
mkdir -p $out/bin
buildCommand =
let
setBasepath = "+set fs_basepath ${env}";
in
lib.optionalString stdenv.hostPlatform.isLinux ''
mkdir -p $out/bin
# We add Mesa to the end of $LD_LIBRARY_PATH to provide fallback
# software rendering. GCC is needed so that libgcc_s.so can be found
# when Mesa is used.
makeWrapper ${env}/bin/ioquake3* $out/bin/quake3 \
--suffix-each LD_LIBRARY_PATH ':' "${libPath}" \
--add-flags "+set fs_basepath ${env} +set r_allowSoftwareGL 1"
# We add Mesa to the end of $LD_LIBRARY_PATH to provide fallback
# software rendering. GCC is needed so that libgcc_s.so can be found
# when Mesa is used.
makeWrapper ${env}/bin/ioquake3 $out/bin/${pname} \
--suffix-each LD_LIBRARY_PATH ':' "${libPath}" \
--add-flags "${setBasepath} +set r_allowSoftwareGL 1"
makeWrapper ${env}/bin/ioq3ded* $out/bin/quake3-server \
--add-flags "+set fs_basepath ${env}"
'';
makeWrapper ${env}/bin/ioq3ded $out/bin/${pname}-server \
--add-flags "${setBasepath}"
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir -p $out/Applications $out/bin
makeWrapper ${env}/bin/ioquake3 $out/bin/${pname} \
--add-flags "${setBasepath}"
makeWrapper ${env}/bin/ioq3ded $out/bin/${pname}-server \
--add-flags "${setBasepath}"
cp -RL ${env}/Applications/ioquake3.app/ $out/Applications/${pname}.app
chmod -R +w $out/Applications/
wrapProgram $out/Applications/${pname}.app/Contents/MacOS/ioquake3 \
--add-flags "${setBasepath}"
wrapProgram $out/Applications/${pname}.app/Contents/MacOS/ioq3ded \
--add-flags "${setBasepath}"
'';
meta = {
inherit description;
mainProgram = "${pname}";
inherit ((lib.head paks).meta)
description
longDescription
homepage
license
;
inherit (ioquake3.meta) platforms;
};
}
+11 -16
View File
@@ -15148,22 +15148,17 @@ with pkgs;
protobuf = protobuf_21;
};
quake3wrapper = callPackage ../games/quake3/wrapper { };
quake3demo = quake3wrapper {
name = "quake3-demo-${lib.getVersion quake3demodata}";
description = "Demo of Quake 3 Arena, a classic first-person shooter";
paks = [
quake3pointrelease
quake3demodata
];
};
quake3demodata = callPackage ../games/quake3/content/demo.nix { };
quake3pointrelease = callPackage ../games/quake3/content/pointrelease.nix { };
quake3hires = callPackage ../games/quake3/content/hires.nix { };
inherit (import ../games/quake3 pkgs.callPackage)
quake3wrapper
quake3arenadata
quake3demodata
quake3pointrelease
quake3arena
quake3arena-hires
quake3demo
quake3demo-hires
quake3hires
;
quakespasm = callPackage ../games/quakespasm { };
vkquake = callPackage ../games/quakespasm/vulkan.nix { };