Skip to content

Commit 733005c

Browse files
authored
q2pro: 3510 -> 0-unstable-2025-01-02 (NixOS#357496)
2 parents 229bce0 + 410c4e0 commit 733005c

File tree

2 files changed

+66
-10
lines changed

2 files changed

+66
-10
lines changed

pkgs/by-name/q2/q2pro/package.nix

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,40 @@
1919
libdecor,
2020
ffmpeg,
2121
wayland-scanner,
22-
makeWrapper,
22+
makeBinaryWrapper,
2323
versionCheckHook,
24+
copyDesktopItems,
25+
makeDesktopItem,
26+
desktopToDarwinBundle,
2427
x11Support ? stdenv.hostPlatform.isLinux,
2528
waylandSupport ? stdenv.hostPlatform.isLinux,
2629
}:
2730

2831
stdenv.mkDerivation (finalAttrs: rec {
2932
pname = "q2pro";
30-
version = "3510";
33+
version = "0-unstable-2025-01-02";
3134

3235
src = fetchFromGitHub {
3336
owner = "skullernet";
3437
repo = "q2pro";
35-
tag = "r${version}";
36-
hash = "sha256-LNOrGJarXnf4QqFXDkUfUgLGrjSqbjncpIN2yttbMuk=";
38+
rev = "5b2d9f29aa9fb07cfe2b4ba9ee628a0153e759c2";
39+
hash = "sha256-vz7f6isv3pcMtr3hO96sV1G2F94/w431FxtB6DcpCVU=";
3740
};
3841

42+
# build date and rev number is displayed in the game's console
43+
revCount = "3660"; # git rev-list --count ${src.rev}
44+
SOURCE_DATE_EPOCH = "1735838714"; # git show -s --format=%ct ${src.rev}
45+
3946
nativeBuildInputs =
4047
[
4148
meson
4249
pkg-config
4350
ninja
44-
makeWrapper
51+
makeBinaryWrapper
52+
copyDesktopItems
4553
]
46-
++ lib.optionals waylandSupport [
47-
wayland-scanner
48-
];
54+
++ lib.optional waylandSupport wayland-scanner
55+
++ lib.optional stdenv.hostPlatform.isDarwin desktopToDarwinBundle;
4956

5057
buildInputs =
5158
[
@@ -64,7 +71,7 @@ stdenv.mkDerivation (finalAttrs: rec {
6471
wayland-protocols
6572
libdecor
6673
]
67-
++ lib.optionals x11Support [ libXi ];
74+
++ lib.optional x11Support libXi;
6875

6976
mesonBuildType = "release";
7077

@@ -79,8 +86,9 @@ stdenv.mkDerivation (finalAttrs: rec {
7986
(lib.mesonEnable "windows-crash-dumps" false)
8087
];
8188

89+
internalVersion = "r${revCount}~${builtins.substring 0 8 src.rev}";
8290
postPatch = ''
83-
echo 'r${version}' > VERSION
91+
echo '${internalVersion}' > VERSION
8492
'';
8593

8694
postInstall =
@@ -92,12 +100,37 @@ stdenv.mkDerivation (finalAttrs: rec {
92100
mv -v $out/bin/q2pro $out/bin/q2pro-unwrapped
93101
makeWrapper $out/bin/q2pro-unwrapped $out/bin/q2pro \
94102
--prefix ${ldLibraryPathEnvName} : "${lib.makeLibraryPath finalAttrs.buildInputs}"
103+
104+
install -D ${src}/src/unix/res/q2pro.xpm $out/share/icons/hicolor/32x32/apps/q2pro.xpm
95105
'';
96106

97107
nativeInstallCheckInputs = [ versionCheckHook ];
98108
versionCheckProgramArg = "--version";
109+
preVersionCheck = ''
110+
export version='${internalVersion}'
111+
'';
99112
doInstallCheck = true;
100113

114+
desktopItems = [
115+
(makeDesktopItem {
116+
name = "q2pro";
117+
desktopName = "Q2PRO";
118+
exec = if stdenv.hostPlatform.isDarwin then "q2pro" else "q2pro +connect %u";
119+
icon = "q2pro";
120+
terminal = false;
121+
mimeTypes = [
122+
"x-scheme-handler/quake2"
123+
];
124+
type = "Application";
125+
categories = [
126+
"Game"
127+
"ActionGame"
128+
];
129+
})
130+
];
131+
132+
passthru.updateScript = ./update.sh;
133+
101134
meta = {
102135
description = "Enhanced Quake 2 client and server focused on multiplayer";
103136
homepage = "https://github.com/skullernet/q2pro";

pkgs/by-name/q2/q2pro/update.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell -i bash -p git common-updater-scripts
3+
set -euo pipefail
4+
5+
attr="q2pro"
6+
7+
tmpdir=$(mktemp -d "/tmp/$attr.XXX")
8+
repo="$tmpdir/repo"
9+
trap 'rm -rf $tmpdir' EXIT
10+
11+
git clone https://github.com/skullernet/q2pro.git "$repo"
12+
13+
rev="$(git -C "$repo" rev-parse HEAD)"
14+
revCount="$(git -C "$repo" rev-list --count HEAD)"
15+
sourceDate="$(git -C "$repo" show -s --format=%cd --date=format:'%Y-%m-%d' HEAD)"
16+
sourceDateEpoch="$(git -C "$repo" show -s --format=%ct HEAD)"
17+
version="0-unstable-$sourceDate"
18+
19+
echo "Updating q2pro to version $version (rev: $rev, date: $sourceDateEpoch)"
20+
21+
update-source-version "$attr" "$version" --rev="${rev}"
22+
update-source-version "$attr" "$revCount" --ignore-same-hash --version-key=revCount
23+
update-source-version "$attr" "$sourceDateEpoch" --ignore-same-hash --version-key=SOURCE_DATE_EPOCH

0 commit comments

Comments
 (0)