Merge pull request #118921 from necessarily-equal/unvanquished

This commit is contained in:
Sandro 2021-06-05 17:20:56 +02:00 committed by GitHub
commit db0abdd87e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 203 additions and 0 deletions

View file

@ -300,6 +300,12 @@
githubId = 335271;
name = "James Alexander Feldman-Crough";
};
afontain = {
email = "antoine.fontaine@epfl.ch";
github = "necessarily-equal";
githubId = 59283660;
name = "Antoine Fontaine";
};
aforemny = {
email = "aforemny@posteo.de";
github = "aforemny";

View file

@ -12,6 +12,8 @@
, mimeType ? null
, categories ? null
, startupNotify ? null
, noDisplay ? null
, prefersNonDefaultGPU ? null
, extraDesktopEntries ? { } # Extra key-value pairs to add to the [Desktop Entry] section. This may override other values
, extraEntries ? "" # Extra configuration. Will be appended to the end of the file and may thus contain extra sections
, fileValidation ? true # whether to validate resulting desktop file.
@ -35,6 +37,8 @@ let
"MimeType" = nullableToString mimeType;
"Categories" = nullableToString categories;
"StartupNotify" = nullableToString startupNotify;
"NoDisplay" = nullableToString noDisplay;
"PrefersNonDefaultGPU" = nullableToString prefersNonDefaultGPU;
} // extraDesktopEntries;
# Map all entries to a list of lines

View file

@ -0,0 +1,191 @@
{ lib, stdenv, fetchzip, fetchurl, fetchFromGitHub, buildFHSUserEnv
, runCommandNoCC, makeDesktopItem, copyDesktopItems, gcc, cmake, gmp
, libGL, zlib, ncurses, geoip, lua5, nettle, curl, SDL2, freetype, glew
, openal, libopus, opusfile, libogg, libvorbis, libjpeg, libwebp, libpng
, cacert, aria2 # to download assets
}:
let
version = "0.52.0";
binary-deps-version = "5";
src = fetchFromGitHub {
owner = "Unvanquished";
repo = "Unvanquished";
rev = "v${version}";
fetchSubmodules = true;
sha256 = "1acda1559q6zwmhg3x00nai88hy83i5hcfli2bqfab7slr95lm27";
};
unvanquished-binary-deps = stdenv.mkDerivation rec {
# DISCLAIMER: this is selected binary crap from the NaCl SDK
name = "unvanquished-binary-deps";
version = binary-deps-version;
src = fetchzip {
url = "https://dl.unvanquished.net/deps/linux64-${version}.tar.bz2";
sha256 = "08bpyavbh5lmyprvqqi59gnm8s1fjmlk9f1785wlv7f52d9f9z1p";
};
dontPatchELF = true;
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
'';
preCheck = "pnacl/bin/clang -v"; # check it links correctly
installPhase = ''
runHook preInstall
mkdir -p $out
cp -R ./* $out/
runHook postInstall
'';
};
libstdcpp-preload-for-unvanquished-nacl = stdenv.mkDerivation {
name = "libstdcpp-preload-for-unvanquished-nacl";
buildCommand = ''
mkdir $out/etc -p
echo ${gcc.cc.lib}/lib/libstdc++.so.6 > $out/etc/ld-nix.so.preload
'';
propagatedBuildInputs = [ gcc.cc.lib ];
};
fhsEnv = buildFHSUserEnv {
name = "unvanquished-fhs-wrapper";
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;
outputHash = "sha256:1fy85cjnjk9rrqkhgx5701inff2yv14hnxglzx3209c553gn31n7";
outputHashMode = "recursive";
nativeBuildInputs = [ aria2 cacert ];
buildCommand = "bash $src/download-paks $out";
};
# 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 = ''
mkdir daemon/external_deps/linux64-${binary-deps-version}/
cp -r ${unvanquished-binary-deps}/* daemon/external_deps/linux64-${binary-deps-version}/
chmod +w -R daemon/external_deps/linux64-${binary-deps-version}/
'';
nativeBuildInputs = [ cmake unvanquished-binary-deps copyDesktopItems ];
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"
];
desktopItems = [
(makeDesktopItem {
name = "net.unvanquished.Unvanquished.desktop";
desktopName = "Unvanquished";
comment = "FPS/RTS Game - Aliens vs. Humans";
icon = "unvanquished";
terminal = false;
exec = "unvanquished";
categories = "Game;ActionGame;StrategyGame;";
# May or may not work
prefersNonDefaultGPU = true;
fileValidation = false; # it doesn't like PrefersNonDefaultGPU
# yes, PrefersNonDefaultGPU is standard:
# https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html
})
(makeDesktopItem {
name = "net.unvanquished.UnvanquishedProtocolHandler.desktop";
desktopName = "Unvanquished (protocol handler)";
noDisplay = true;
terminal = false;
exec = "unvanquished -connect %u";
mimeType = "x-scheme-handler/unv";
# May or may not work
prefersNonDefaultGPU = true;
fileValidation = false; # it doesn't like PrefersNonDefaultGPU
})
];
installPhase = ''
runHook preInstall
for f in daemon daemon-tty daemonded nacl_loader nacl_helper_bootstrap; do
install -Dm0755 -t $out/lib/ $f
done
install -Dm0644 -t $out/lib/ irt_core-x86_64.nexe
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
'';
meta = {
platforms = [ "x86_64-linux" ];
homepage = "https://unvanquished.net/";
downloadPage = "https://unvanquished.net/download/";
description = "A fast paced, first person strategy game";
maintainers = with lib.maintainers; [ afontain ];
# don't replace the following lib.licenses.zlib with just "zlib",
# or you would end up with the package instead
license = with lib.licenses; [
mit gpl3Only lib.licenses.zlib cc-by-sa-25
];
};
}

View file

@ -9384,6 +9384,8 @@ in
untrunc-anthwlock = callPackage ../tools/video/untrunc-anthwlock { };
unvanquished = callPackage ../games/unvanquished { };
up = callPackage ../tools/misc/up { };
upterm = callPackage ../tools/misc/upterm { };