Skip to content

Commit

Permalink
q2pro: 3510 -> 3626
Browse files Browse the repository at this point in the history
  • Loading branch information
carlossless committed Nov 22, 2024
1 parent 39e98fa commit d24acc7
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 10 deletions.
48 changes: 38 additions & 10 deletions pkgs/by-name/q2/q2pro/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,39 @@
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 = "3626"; # git rev-list --count ${src.rev}

src = fetchFromGitHub {
owner = "skullernet";
repo = "q2pro";
rev = "refs/tags/r${version}";
hash = "sha256-LNOrGJarXnf4QqFXDkUfUgLGrjSqbjncpIN2yttbMuk=";
rev = "cd3f69e66b83931c2c34841099784fb0e91d7dad";
hash = "sha256-OTrya0OF4D0XbW1OtApAx5F+XqLoCIUsn2OvwCHwVVk=";
};

# build date is displayed in the game's console
SOURCE_DATE_EPOCH = 1732218854; # 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 =
[
Expand All @@ -64,7 +70,7 @@ stdenv.mkDerivation (finalAttrs: rec {
wayland-protocols
libdecor
]
++ lib.optionals x11Support [ libXi ];
++ lib.optional x11Support libXi;

mesonBuildType = "release";

Expand All @@ -80,7 +86,7 @@ stdenv.mkDerivation (finalAttrs: rec {
];

postPatch = ''
echo 'r${version}' > VERSION
echo 'r${version}~${builtins.substring 0 8 src.rev}' > VERSION
'';

postInstall =
Expand All @@ -92,12 +98,34 @@ 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";
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";
Expand Down
31 changes: 31 additions & 0 deletions pkgs/by-name/q2/q2pro/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p git common-updater-scripts
set -euo pipefail

attr="q2pro"

pkgDir=$(dirname "${BASH_SOURCE[@]}")
nixFile="$pkgDir/package.nix"
nixpkgsRoot=$(cd "$pkgDir" && git rev-parse --show-toplevel)

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=%ct HEAD)"
version="$revCount"

echo "Updating q2pro to version $version (rev: $rev, date: $sourceDate)"

update-source-version "$attr" "$version" --rev="${rev}" --file="${nixFile}"

oldSourceDate=$(nix eval -f "$nixpkgsRoot/default.nix" "$attr.SOURCE_DATE_EPOCH")
if [ "$oldSourceDate" != "$sourceDate" ]; then
sed -i -re "/\bSOURCE_DATE_EPOCH\b\s*=/ s|$oldSourceDate|$sourceDate|" "$nixFile"
else
echo "SOURCE_DATE_EPOCH is already up to date"
fi

0 comments on commit d24acc7

Please sign in to comment.