classicube: init at 1.3.2 (#189491)
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
This commit is contained in:
parent
b41f6fe581
commit
aa4f7078b9
87
pkgs/games/classicube/default.nix
Normal file
87
pkgs/games/classicube/default.nix
Normal file
@ -0,0 +1,87 @@
|
||||
{ lib
|
||||
, stdenv
|
||||
, fetchFromGitHub
|
||||
, dos2unix
|
||||
, makeWrapper
|
||||
, SDL2
|
||||
, libGL
|
||||
, curl
|
||||
, openal
|
||||
, liberation_ttf
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "ClassiCube";
|
||||
version = "1.3.2";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "UnknownShadow200";
|
||||
repo = "ClassiCube";
|
||||
rev = version;
|
||||
sha256 = "6a0f7b03ef3a7f74cf42ffa5b88ab1a7b7beb4d864871a1b700465343ae74bb6";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ dos2unix makeWrapper ];
|
||||
|
||||
prePatch = ''
|
||||
# The ClassiCube sources have DOS-style newlines
|
||||
# which causes problems with diff/patch.
|
||||
dos2unix 'src/Platform_Posix.c' 'src/Core.h'
|
||||
'';
|
||||
|
||||
patches = [
|
||||
# Fix hardcoded font paths
|
||||
./font-location.patch
|
||||
# ClassiCube doesn't compile with its X11 backend
|
||||
# because of issues with libXi.
|
||||
./use-sdl.patch
|
||||
# For some reason, the Makefile doesn't link
|
||||
# with libcurl and openal when ClassiCube requires them.
|
||||
# Also links with SDL2 instead of libX11 and libXi.
|
||||
./fix-linking.patch
|
||||
];
|
||||
|
||||
font_path = "${liberation_ttf}/share/fonts/truetype";
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
postPatch = ''
|
||||
# ClassiCube hardcodes locations of fonts.
|
||||
# This changes the hardcoded location
|
||||
# to the path of liberation_ttf instead
|
||||
substituteInPlace src/Platform_Posix.c \
|
||||
--replace '%NIXPKGS_FONT_PATH%' "${font_path}"
|
||||
# ClassiCube's Makefile hardcodes JOBS=1 for some reason,
|
||||
# even though it works perfectly well multi-threaded.
|
||||
substituteInPlace src/Makefile \
|
||||
--replace 'JOBS=1' "JOBS=$NIX_BUILD_CORES"
|
||||
'';
|
||||
|
||||
buildInputs = [ SDL2 libGL curl openal liberation_ttf ];
|
||||
|
||||
preBuild = "cd src";
|
||||
|
||||
postBuild = "cd -";
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p "$out/bin"
|
||||
cp 'src/ClassiCube' "$out/bin"
|
||||
# ClassiCube puts downloaded resources
|
||||
# next to the location of the executable by default.
|
||||
# This doesn't work with Nix
|
||||
# as the location of the executable is read-only.
|
||||
# We wrap the program to make it put its resources
|
||||
# in ~/.local/share instead.
|
||||
wrapProgram "$out/bin/ClassiCube" \
|
||||
--run 'mkdir -p "$HOME/.local/share/ClassiCube"' \
|
||||
--add-flags '-d"$HOME/.local/share/ClassiCube"'
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://www.classicube.net/";
|
||||
description = "A lightweight, custom Minecraft Classic/ClassiCube client with optional additions written from scratch in C";
|
||||
license = licenses.bsd3;
|
||||
platforms = platforms.linux;
|
||||
maintainers = with maintainers; [ _360ied ];
|
||||
};
|
||||
}
|
13
pkgs/games/classicube/fix-linking.patch
Normal file
13
pkgs/games/classicube/fix-linking.patch
Normal file
@ -0,0 +1,13 @@
|
||||
diff --git a/src/Makefile b/src/Makefile
|
||||
index 83188ce..3439cdb 100644
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -40,7 +40,7 @@ LIBS=-mwindows -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -ld3d9
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT),linux)
|
||||
-LIBS=-lX11 -lXi -lpthread -lGL -lm -ldl
|
||||
+LIBS=-lSDL2 -lpthread -lGL -lm -ldl -lcurl -lopenal
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT),sunos)
|
16
pkgs/games/classicube/font-location.patch
Normal file
16
pkgs/games/classicube/font-location.patch
Normal file
@ -0,0 +1,16 @@
|
||||
diff --git a/src/Platform_Posix.c b/src/Platform_Posix.c
|
||||
index bca992d..3540afa 100644
|
||||
--- a/src/Platform_Posix.c
|
||||
+++ b/src/Platform_Posix.c
|
||||
@@ -440,9 +440,8 @@ void Platform_LoadSysFonts(void) {
|
||||
String_FromConst("/Library/Fonts")
|
||||
};
|
||||
#else
|
||||
- static const cc_string dirs[2] = {
|
||||
- String_FromConst("/usr/share/fonts"),
|
||||
- String_FromConst("/usr/local/share/fonts")
|
||||
+ static const cc_string dirs[1] = {
|
||||
+ String_FromConst("%NIXPKGS_FONT_PATH%")
|
||||
};
|
||||
#endif
|
||||
for (i = 0; i < Array_Elems(dirs); i++) {
|
13
pkgs/games/classicube/use-sdl.patch
Normal file
13
pkgs/games/classicube/use-sdl.patch
Normal file
@ -0,0 +1,13 @@
|
||||
diff --git a/src/Core.h b/src/Core.h
|
||||
index e94a39e..96527d0 100644
|
||||
--- a/src/Core.h
|
||||
+++ b/src/Core.h
|
||||
@@ -170,7 +170,7 @@ Thus it is **NOT SAFE** to allocate a string on the stack. */
|
||||
#define CC_BUILD_LINUX
|
||||
#define CC_BUILD_POSIX
|
||||
#define CC_BUILD_GL
|
||||
-#define CC_BUILD_X11
|
||||
+#define CC_BUILD_SDL
|
||||
#define CC_BUILD_CURL
|
||||
#define CC_BUILD_OPENAL
|
||||
#if defined CC_BUILD_RPI
|
@ -368,6 +368,8 @@ with pkgs;
|
||||
|
||||
chrysalis = callPackage ../applications/misc/chrysalis { };
|
||||
|
||||
classicube = callPackage ../games/classicube { };
|
||||
|
||||
clj-kondo = callPackage ../development/tools/clj-kondo { };
|
||||
|
||||
cloak = callPackage ../applications/misc/cloak {
|
||||
|
Loading…
Reference in New Issue
Block a user