q2pro: 3510 -> 0-unstable-2025-01-02 (#357496)

This commit is contained in:
misuzu
2025-01-15 20:20:17 +02:00
committed by GitHub
2 changed files with 66 additions and 10 deletions
+43 -10
View File
@@ -19,33 +19,40 @@
libdecor,
ffmpeg,
wayland-scanner,
makeWrapper,
makeBinaryWrapper,
versionCheckHook,
copyDesktopItems,
makeDesktopItem,
desktopToDarwinBundle,
x11Support ? stdenv.hostPlatform.isLinux,
waylandSupport ? stdenv.hostPlatform.isLinux,
}:
stdenv.mkDerivation (finalAttrs: rec {
pname = "q2pro";
version = "3510";
version = "0-unstable-2025-01-02";
src = fetchFromGitHub {
owner = "skullernet";
repo = "q2pro";
tag = "r${version}";
hash = "sha256-LNOrGJarXnf4QqFXDkUfUgLGrjSqbjncpIN2yttbMuk=";
rev = "5b2d9f29aa9fb07cfe2b4ba9ee628a0153e759c2";
hash = "sha256-vz7f6isv3pcMtr3hO96sV1G2F94/w431FxtB6DcpCVU=";
};
# build date and rev number is displayed in the game's console
revCount = "3660"; # git rev-list --count ${src.rev}
SOURCE_DATE_EPOCH = "1735838714"; # git show -s --format=%ct ${src.rev}
nativeBuildInputs =
[
meson
pkg-config
ninja
makeWrapper
makeBinaryWrapper
copyDesktopItems
]
++ lib.optionals waylandSupport [
wayland-scanner
];
++ lib.optional waylandSupport wayland-scanner
++ lib.optional stdenv.hostPlatform.isDarwin desktopToDarwinBundle;
buildInputs =
[
@@ -64,7 +71,7 @@ stdenv.mkDerivation (finalAttrs: rec {
wayland-protocols
libdecor
]
++ lib.optionals x11Support [ libXi ];
++ lib.optional x11Support libXi;
mesonBuildType = "release";
@@ -79,8 +86,9 @@ stdenv.mkDerivation (finalAttrs: rec {
(lib.mesonEnable "windows-crash-dumps" false)
];
internalVersion = "r${revCount}~${builtins.substring 0 8 src.rev}";
postPatch = ''
echo 'r${version}' > VERSION
echo '${internalVersion}' > VERSION
'';
postInstall =
@@ -92,12 +100,37 @@ stdenv.mkDerivation (finalAttrs: rec {
mv -v $out/bin/q2pro $out/bin/q2pro-unwrapped
makeWrapper $out/bin/q2pro-unwrapped $out/bin/q2pro \
--prefix ${ldLibraryPathEnvName} : "${lib.makeLibraryPath finalAttrs.buildInputs}"
install -D ${src}/src/unix/res/q2pro.xpm $out/share/icons/hicolor/32x32/apps/q2pro.xpm
'';
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = "--version";
preVersionCheck = ''
export version='${internalVersion}'
'';
doInstallCheck = true;
desktopItems = [
(makeDesktopItem {
name = "q2pro";
desktopName = "Q2PRO";
exec = if stdenv.hostPlatform.isDarwin then "q2pro" else "q2pro +connect %u";
icon = "q2pro";
terminal = false;
mimeTypes = [
"x-scheme-handler/quake2"
];
type = "Application";
categories = [
"Game"
"ActionGame"
];
})
];
passthru.updateScript = ./update.sh;
meta = {
description = "Enhanced Quake 2 client and server focused on multiplayer";
homepage = "https://github.com/skullernet/q2pro";
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p git common-updater-scripts
set -euo pipefail
attr="q2pro"
tmpdir=$(mktemp -d "/tmp/$attr.XXX")
repo="$tmpdir/repo"
trap 'rm -rf $tmpdir' EXIT
git clone https://github.com/skullernet/q2pro.git "$repo"
rev="$(git -C "$repo" rev-parse HEAD)"
revCount="$(git -C "$repo" rev-list --count HEAD)"
sourceDate="$(git -C "$repo" show -s --format=%cd --date=format:'%Y-%m-%d' HEAD)"
sourceDateEpoch="$(git -C "$repo" show -s --format=%ct HEAD)"
version="0-unstable-$sourceDate"
echo "Updating q2pro to version $version (rev: $rev, date: $sourceDateEpoch)"
update-source-version "$attr" "$version" --rev="${rev}"
update-source-version "$attr" "$revCount" --ignore-same-hash --version-key=revCount
update-source-version "$attr" "$sourceDateEpoch" --ignore-same-hash --version-key=SOURCE_DATE_EPOCH