2022-06-16 17:23:12 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchzip
|
|
|
|
, fetchFromGitHub
|
2022-06-26 10:26:21 +00:00
|
|
|
, fetchpatch
|
2022-06-16 17:23:12 +00:00
|
|
|
, SDL2
|
2023-04-29 16:46:19 +00:00
|
|
|
, buildFHSEnv
|
2022-06-16 17:23:12 +00:00
|
|
|
, cmake
|
|
|
|
, copyDesktopItems
|
|
|
|
, curl
|
|
|
|
, freetype
|
|
|
|
, gcc
|
|
|
|
, geoip
|
|
|
|
, glew
|
|
|
|
, gmp
|
|
|
|
, libGL
|
|
|
|
, libjpeg
|
|
|
|
, libogg
|
|
|
|
, libopus
|
|
|
|
, libpng
|
|
|
|
, libvorbis
|
|
|
|
, libwebp
|
|
|
|
, lua5
|
|
|
|
, makeDesktopItem
|
|
|
|
, ncurses
|
|
|
|
, nettle
|
|
|
|
, openal
|
|
|
|
, opusfile
|
|
|
|
, zlib
|
|
|
|
# to download assets
|
|
|
|
, aria2
|
|
|
|
, cacert
|
2021-06-06 07:54:09 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2023-02-09 11:40:11 +00:00
|
|
|
version = "0.54.0";
|
|
|
|
binary-deps-version = "8";
|
2021-06-06 07:54:09 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Unvanquished";
|
|
|
|
repo = "Unvanquished";
|
|
|
|
rev = "v${version}";
|
|
|
|
fetchSubmodules = true;
|
2023-02-09 11:40:11 +00:00
|
|
|
sha256 = "sha256-X2c6BHI4W6fOurLiBWIBZzJrZ+7RHMEwN8GJGz6e350=";
|
2021-06-06 07:54:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unvanquished-binary-deps = stdenv.mkDerivation rec {
|
|
|
|
# DISCLAIMER: this is selected binary crap from the NaCl SDK
|
|
|
|
name = "unvanquished-binary-deps";
|
|
|
|
version = binary-deps-version;
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2021-06-06 07:54:09 +00:00
|
|
|
src = fetchzip {
|
2023-02-09 11:40:11 +00:00
|
|
|
url = "https://dl.unvanquished.net/deps/linux-amd64-default_${version}.tar.xz ";
|
|
|
|
sha256 = "sha256-6r9j0HRMDC/7i8f4f5bBK4NmwsTpSChHrRWwz0ENAZo=";
|
2021-06-06 07:54:09 +00:00
|
|
|
};
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2021-06-06 07:54:09 +00:00
|
|
|
dontPatchELF = true;
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2021-06-06 07:54:09 +00:00
|
|
|
preFixup = ''
|
|
|
|
# We are not using the autoPatchelfHook, because it would make
|
|
|
|
# nacl_bootstrap_helper unable to load nacl_loader:
|
|
|
|
# "nacl_loader: ELF file has unreasonable e_phnum=13"
|
|
|
|
interpreter="$(< "$NIX_CC/nix-support/dynamic-linker")"
|
|
|
|
for f in pnacl/bin/*; do
|
|
|
|
if [ -f "$f" && -x "$f" ]; then
|
|
|
|
echo "Patching $f"
|
|
|
|
patchelf --set-interpreter "$interpreter" "$f"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
'';
|
2022-06-16 17:23:12 +00:00
|
|
|
|
|
|
|
preCheck = ''
|
|
|
|
# check it links correctly
|
|
|
|
pnacl/bin/clang -v
|
|
|
|
'';
|
|
|
|
|
2021-06-06 07:54:09 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out
|
|
|
|
cp -R ./* $out/
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
libstdcpp-preload-for-unvanquished-nacl = stdenv.mkDerivation {
|
|
|
|
name = "libstdcpp-preload-for-unvanquished-nacl";
|
2022-06-16 17:23:12 +00:00
|
|
|
|
|
|
|
propagatedBuildInputs = [ gcc.cc.lib ];
|
|
|
|
|
2021-06-06 07:54:09 +00:00
|
|
|
buildCommand = ''
|
|
|
|
mkdir $out/etc -p
|
|
|
|
echo ${gcc.cc.lib}/lib/libstdc++.so.6 > $out/etc/ld-nix.so.preload
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
fhsEnv = buildFHSEnv {
|
2021-06-06 07:54:09 +00:00
|
|
|
name = "unvanquished-fhs-wrapper";
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2021-06-06 07:54:09 +00:00
|
|
|
targetPkgs = pkgs: [ libstdcpp-preload-for-unvanquished-nacl ];
|
|
|
|
};
|
|
|
|
|
|
|
|
wrapBinary = binary: wrappername: ''
|
|
|
|
cat > $out/lib/${binary}-wrapper <<-EOT
|
|
|
|
#!/bin/sh
|
|
|
|
exec $out/lib/${binary} -pakpath ${unvanquished-assets} "\$@"
|
|
|
|
EOT
|
|
|
|
chmod +x $out/lib/${binary}-wrapper
|
|
|
|
|
|
|
|
cat > $out/bin/${wrappername} <<-EOT
|
|
|
|
#!/bin/sh
|
|
|
|
exec ${fhsEnv}/bin/unvanquished-fhs-wrapper $out/lib/${binary}-wrapper "\$@"
|
|
|
|
EOT
|
|
|
|
chmod +x $out/bin/${wrappername}
|
|
|
|
'';
|
|
|
|
|
|
|
|
unvanquished-assets = stdenv.mkDerivation {
|
|
|
|
pname = "unvanquished-assets";
|
|
|
|
inherit version src;
|
|
|
|
|
2023-02-09 11:40:11 +00:00
|
|
|
outputHash = "sha256-ua9Q5E5C4t8z/yNQp6qn1i9NNDAk4ohzvgpMbCBxb8Q=";
|
2021-06-06 07:54:09 +00:00
|
|
|
outputHashMode = "recursive";
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2021-06-06 07:54:09 +00:00
|
|
|
nativeBuildInputs = [ aria2 cacert ];
|
2022-06-16 17:23:12 +00:00
|
|
|
|
|
|
|
buildCommand = ''
|
|
|
|
bash $src/download-paks --cache=$(pwd) --version=${version} $out
|
|
|
|
'';
|
2021-06-06 07:54:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# this really is the daemon game engine, the game itself is in the assets
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
pname = "unvanquished";
|
|
|
|
inherit version src binary-deps-version;
|
|
|
|
|
|
|
|
preConfigure = ''
|
2023-02-09 11:40:11 +00:00
|
|
|
TARGET="linux-amd64-default_${binary-deps-version}"
|
|
|
|
mkdir daemon/external_deps/"$TARGET"
|
|
|
|
cp -r ${unvanquished-binary-deps}/* daemon/external_deps/"$TARGET"/
|
|
|
|
chmod +w -R daemon/external_deps/"$TARGET"/
|
2021-06-06 07:54:09 +00:00
|
|
|
'';
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
unvanquished-binary-deps
|
|
|
|
copyDesktopItems
|
|
|
|
];
|
|
|
|
|
2021-06-06 07:54:09 +00:00
|
|
|
buildInputs = [
|
|
|
|
gmp
|
|
|
|
libGL
|
|
|
|
zlib
|
|
|
|
ncurses
|
|
|
|
geoip
|
|
|
|
lua5
|
|
|
|
nettle
|
|
|
|
curl
|
|
|
|
SDL2
|
|
|
|
freetype
|
|
|
|
glew
|
|
|
|
openal
|
|
|
|
libopus
|
|
|
|
opusfile
|
|
|
|
libogg
|
|
|
|
libvorbis
|
|
|
|
libjpeg
|
|
|
|
libwebp
|
|
|
|
libpng
|
|
|
|
];
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DBUILD_CGAME=NO"
|
|
|
|
"-DBUILD_SGAME=NO"
|
|
|
|
"-DUSE_HARDENING=TRUE"
|
|
|
|
"-DUSE_LTO=TRUE"
|
2021-06-28 23:13:55 +00:00
|
|
|
"-DOpenGL_GL_PREFERENCE=LEGACY" # https://github.com/DaemonEngine/Daemon/issues/474
|
2021-06-06 07:54:09 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
desktopItems = [
|
|
|
|
(makeDesktopItem {
|
|
|
|
name = "net.unvanquished.Unvanquished.desktop";
|
|
|
|
desktopName = "Unvanquished";
|
|
|
|
comment = "FPS/RTS Game - Aliens vs. Humans";
|
|
|
|
icon = "unvanquished";
|
|
|
|
exec = "unvanquished";
|
2022-03-05 16:20:37 +00:00
|
|
|
categories = [ "Game" "ActionGame" "StrategyGame" ];
|
2021-06-06 07:54:09 +00:00
|
|
|
prefersNonDefaultGPU = true;
|
|
|
|
})
|
|
|
|
(makeDesktopItem {
|
|
|
|
name = "net.unvanquished.UnvanquishedProtocolHandler.desktop";
|
|
|
|
desktopName = "Unvanquished (protocol handler)";
|
|
|
|
noDisplay = true;
|
|
|
|
exec = "unvanquished -connect %u";
|
2022-03-05 16:20:37 +00:00
|
|
|
mimeTypes = [ "x-scheme-handler/unv" ];
|
2021-06-06 07:54:09 +00:00
|
|
|
prefersNonDefaultGPU = true;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
for f in daemon daemon-tty daemonded nacl_loader nacl_helper_bootstrap; do
|
|
|
|
install -Dm0755 -t $out/lib/ $f
|
|
|
|
done
|
2023-02-09 11:40:11 +00:00
|
|
|
install -Dm0644 -t $out/lib/ irt_core-amd64.nexe
|
2021-06-06 07:54:09 +00:00
|
|
|
|
|
|
|
mkdir $out/bin/
|
|
|
|
${wrapBinary "daemon" "unvanquished"}
|
|
|
|
${wrapBinary "daemon-tty" "unvanquished-tty"}
|
|
|
|
${wrapBinary "daemonded" "unvanquished-server"}
|
|
|
|
|
|
|
|
for d in ${src}/dist/icons/*; do
|
|
|
|
install -Dm0644 -t $out/share/icons/hicolor/$(basename $d)/apps/ $d/unvanquished.png
|
|
|
|
done
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2021-06-06 07:54:09 +00:00
|
|
|
meta = {
|
|
|
|
homepage = "https://unvanquished.net/";
|
|
|
|
downloadPage = "https://unvanquished.net/download/";
|
|
|
|
description = "A fast paced, first person strategy game";
|
|
|
|
# don't replace the following lib.licenses.zlib with just "zlib",
|
|
|
|
# or you would end up with the package instead
|
|
|
|
license = with lib.licenses; [
|
2021-06-28 23:13:55 +00:00
|
|
|
mit gpl3Plus lib.licenses.zlib bsd3 # engine
|
|
|
|
cc-by-sa-25 cc-by-sa-30 cc-by-30 cc-by-sa-40 cc0 # assets
|
2021-06-06 07:54:09 +00:00
|
|
|
];
|
2022-06-26 10:26:21 +00:00
|
|
|
sourceProvenance = with lib.sourceTypes; [
|
|
|
|
fromSource
|
|
|
|
binaryNativeCode # unvanquished-binary-deps
|
|
|
|
];
|
2022-06-16 17:23:12 +00:00
|
|
|
maintainers = with lib.maintainers; [ afontain ];
|
|
|
|
platforms = [ "x86_64-linux" ];
|
2021-06-06 07:54:09 +00:00
|
|
|
};
|
|
|
|
}
|