Skip to content

Commit 1c53d4b

Browse files
authored
nexusmods-app: 0.14.3 -> 0.15.2 (#433654)
2 parents 3104ac9 + ba60a12 commit 1c53d4b

File tree

9 files changed

+276
-23
lines changed

9 files changed

+276
-23
lines changed

pkgs/by-name/ne/nexusmods-app/deps.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{ fetchurl }:
2+
let
3+
release = "ved4b249e2c35952c";
4+
owner = "Nexus-Mods";
5+
repo = "game-hashes";
6+
repoURL = "https://github.com/${owner}/${repo}";
7+
8+
# Define a binding so that `update-source-version` can find it
9+
src = fetchurl {
10+
url = "${repoURL}/releases/download/${release}/game_hashes_db.zip";
11+
hash = "sha256-9xJ8yfLRkIV0o++NHK2igd2l83/tsgWc5cuwZO2zseY=";
12+
passthru = {
13+
inherit
14+
src # Also for `update-source-version` support
15+
release
16+
owner
17+
repo
18+
repoURL
19+
;
20+
};
21+
};
22+
in
23+
src
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env nix-shell
2+
#! nix-shell -i bash -p bash common-updater-scripts gh
3+
4+
set -eu -o pipefail
5+
6+
# Set a default attrpath to allow running this update script directly
7+
export UPDATE_NIX_ATTR_PATH="${UPDATE_NIX_ATTR_PATH:-"nexusmods-app.gameHashes"}"
8+
9+
self=$(realpath "$0")
10+
dir=$(dirname "$self")
11+
cd "$dir"/../../../../../
12+
13+
old_release=$(
14+
nix-instantiate --eval --raw \
15+
--attr "$UPDATE_NIX_ATTR_PATH.release"
16+
)
17+
18+
echo "Looking up latest game_hashes_db" >&2
19+
new_release=$(
20+
gh --repo Nexus-Mods/game-hashes \
21+
release list \
22+
--limit 1 \
23+
--exclude-drafts \
24+
--exclude-pre-releases \
25+
--json tagName \
26+
--jq .[].tagName
27+
)
28+
29+
echo "Latest release is $new_release" >&2
30+
31+
if [ "$old_release" = "$new_release" ]; then
32+
echo "Already up to date"
33+
exit
34+
fi
35+
36+
old_release_escaped=$(echo "$old_release" | sed 's#[$^*\\.[|]#\\&#g')
37+
new_release_escaped=$(echo "$new_release" | sed 's#[$^*\\.[|]#\\&#g')
38+
url=$(
39+
nix-instantiate --eval --raw --attr "$UPDATE_NIX_ATTR_PATH.url" |
40+
sed "s|$old_release_escaped|$new_release_escaped|"
41+
)
42+
43+
echo "Downloading and hashing game_hashes_db" >&2
44+
hash=$(
45+
nix --extra-experimental-features nix-command \
46+
hash convert --hash-algo sha256 --to sri \
47+
"$(nix-prefetch-url "$url" --type sha256)"
48+
)
49+
50+
echo "Updating source" >&2
51+
update-source-version \
52+
"$UPDATE_NIX_ATTR_PATH" \
53+
"$new_release" \
54+
"$hash" \
55+
--version-key=release \
56+
--file="$dir"/default.nix

pkgs/by-name/ne/nexusmods-app/package.nix

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
_7zz,
33
avalonia,
44
buildDotnetModule,
5+
callPackage,
56
desktop-file-utils,
67
dotnetCorePackages,
78
fetchgit,
89
imagemagick,
910
lib,
1011
xdg-utils,
11-
nix-update-script,
1212
pname ? "nexusmods-app",
1313
}:
1414
let
@@ -23,15 +23,17 @@ let
2323
in
2424
buildDotnetModule (finalAttrs: {
2525
inherit pname;
26-
version = "0.14.3";
26+
version = "0.15.2";
2727

2828
src = fetchgit {
2929
url = "https://github.com/Nexus-Mods/NexusMods.App.git";
3030
rev = "refs/tags/v${finalAttrs.version}";
31-
hash = "sha256-B2gIRVeaTwYEnESMovwEJgdmLwRNA7/nJs7opNhiyyA=";
31+
hash = "sha256-WI6ulYDPOBGGt3snimCHswuIaII1aWNT/TZqvJxrQRQ=";
3232
fetchSubmodules = true;
3333
};
3434

35+
gameHashes = callPackage ./game-hashes { };
36+
3537
enableParallelBuilding = false;
3638

3739
# If the whole solution is published, there seems to be a race condition where
@@ -63,9 +65,18 @@ buildDotnetModule (finalAttrs: {
6365
# for some reason these tests fail (intermittently?) with a zero timestamp
6466
touch tests/NexusMods.UI.Tests/WorkspaceSystem/*.verified.png
6567
66-
# Assertion assumes version is set to 0.0.1
67-
substituteInPlace tests/NexusMods.Telemetry.Tests/TrackingDataSenderTests.cs \
68-
--replace-fail 'cra_ct=v0.0.1' 'cra_ct=v${finalAttrs.version}'
68+
# Specify a fixed date to improve build reproducibility
69+
echo "1970-01-01T00:00:00Z" >buildDate.txt
70+
substituteInPlace src/NexusMods.Sdk/NexusMods.Sdk.csproj \
71+
--replace-fail '$(BaseIntermediateOutputPath)buildDate.txt' "$(realpath buildDate.txt)"
72+
73+
# Use a pinned version of the game hashes db
74+
substituteInPlace src/NexusMods.Games.FileHashes/NexusMods.Games.FileHashes.csproj \
75+
--replace-fail '$(BaseIntermediateOutputPath)games_hashes_db.zip' "$gameHashes"
76+
77+
# Use a vendored version of the nexus API's games.json data
78+
substituteInPlace src/NexusMods.Networking.NexusWebApi/NexusMods.Networking.NexusWebApi.csproj \
79+
--replace-fail '$(BaseIntermediateOutputPath)games.json' ${./vendored/games.json}
6980
'';
7081

7182
makeWrapperArgs = [
@@ -127,6 +138,7 @@ buildDotnetModule (finalAttrs: {
127138

128139
dotnetTestFlags = [
129140
"--environment=USER=nobody"
141+
"--property:Version=${finalAttrs.version}"
130142
"--property:DefineConstants=${lib.strings.concatStringsSep "%3B" constants}"
131143
];
132144

@@ -137,19 +149,9 @@ buildDotnetModule (finalAttrs: {
137149
];
138150

139151
disabledTests = [
140-
# Fails attempting to download game hashes DB from github:
141-
# HttpRequestException : Resource temporarily unavailable (github.com:443)
142-
"NexusMods.DataModel.SchemaVersions.Tests.LegacyDatabaseSupportTests.TestDatabase"
143-
"NexusMods.DataModel.SchemaVersions.Tests.MigrationSpecificTests.TestsFor_0001_ConvertTimestamps.OldTimestampsAreInRange"
144-
"NexusMods.DataModel.SchemaVersions.Tests.MigrationSpecificTests.TestsFor_0003_FixDuplicates.No_Duplicates"
145-
"NexusMods.DataModel.SchemaVersions.Tests.MigrationSpecificTests.TestsFor_0004_RemoveGameFiles.Test"
146-
147152
# Fails attempting to fetch SMAPI version data from github:
148153
# https://github.com/erri120/smapi-versions/raw/main/data/game-smapi-versions.json
149154
"NexusMods.Games.StardewValley.Tests.SMAPIGameVersionDiagnosticEmitterTests.Test_TryGetLastSupportedSMAPIVersion"
150-
151-
# Fails attempting to fetch game info from NexusMods API
152-
"NexusMods.Networking.NexusWebApi.Tests.LocalMappingCacheTests.Test_Parse"
153155
]
154156
++ lib.optionals (!_7zz.meta.unfree) [
155157
"NexusMods.Games.FOMOD.Tests.FomodXmlInstallerTests.InstallsFilesSimple_UsingRar"
@@ -189,12 +191,12 @@ buildDotnetModule (finalAttrs: {
189191
};
190192
};
191193

192-
passthru.updateScript = nix-update-script { };
194+
passthru.updateScript = ./update.sh;
193195

194196
meta = {
195197
mainProgram = "NexusMods.App";
196198
homepage = "https://github.com/Nexus-Mods/NexusMods.App";
197-
changelog = "https://github.com/Nexus-Mods/NexusMods.App/releases/tag/${finalAttrs.src.rev}";
199+
changelog = "https://github.com/Nexus-Mods/NexusMods.App/releases/tag/v${finalAttrs.version}";
198200
license = [ lib.licenses.gpl3Plus ];
199201
maintainers = with lib.maintainers; [
200202
l0b0
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env nix-shell
2+
#! nix-shell -i bash -p bash nix-update
3+
4+
set -eu -o pipefail
5+
6+
# Set a default attrpath to allow running this update script directly
7+
export UPDATE_NIX_ATTR_PATH="${UPDATE_NIX_ATTR_PATH:-"nexusmods-app"}"
8+
9+
self=$(realpath "$0")
10+
dir=$(dirname "$self")
11+
cd "$dir"/../../../../
12+
13+
# Update vendored files
14+
"$dir"/vendored/update.sh
15+
16+
# Update game_hashes_db
17+
UPDATE_NIX_ATTR_PATH="$UPDATE_NIX_ATTR_PATH.gameHashes" \
18+
"$dir"/game-hashes/update.sh
19+
20+
url=$(
21+
nix-instantiate --eval --raw \
22+
--attr "$UPDATE_NIX_ATTR_PATH.meta.homepage"
23+
)
24+
nix-update --url "$url"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
This directory contains a vendored copy of `games.json`, along with tooling to generate it.
2+
3+
## Purpose
4+
5+
The games data is fetched at runtime by NexusMods.App, however it is also included at build time for two reasons:
6+
7+
1. It allows tests to run against real data.
8+
2. It is used as cached data, speeding up the app's initial run.
9+
10+
It is not vital for the file to contain all games, however ideally it should contain all games _supported_ by this version of NexusMods.App.
11+
That way the initial run's cached data is more useful.
12+
13+
If this file grows too large, because we are including too many games, we can patch the `csproj` build spec so that `games.json` is not used at build time.
14+
We would also need to patch or disable any tests that rely on it.
15+
16+
## Generating
17+
18+
`games.json` is generated automatically by `update.sh`, using data from [nexusmods' API][url] and the games listed in `game-ids.nix`.
19+
20+
To add a new game to `games.json`:
21+
- Inspect the [nexusmods endpoint][url] to find the game's name and ID
22+
- Add the name and ID to `game-ids.nix`
23+
- Run `update.sh`
24+
- Commit the result
25+
26+
> [!Note]
27+
> Running `update.sh` may also update the existing games, so you may wish to create two separate commits using `git add --patch`.
28+
> One for updating the existing data and another for adding the new game.
29+
30+
[url]: https://data.nexusmods.com/file/nexus-data/games.json
31+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file lists games to be included in the vendored games.json file.
2+
# It is not critical to include all games, other than those referenced by the test suite.
3+
# Ideally, all games supported by the app will be included, as this can improve first-run performance.
4+
{
5+
# keep-sorted start case=no numeric=yes
6+
"Baldur's Gate 3" = 3474;
7+
"Cyberpunk 2077" = 3333;
8+
"Mount & Blade II: Bannerlord" = 3174;
9+
"Stardew Valley" = 1303;
10+
# keep-sorted end
11+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[
2+
{
3+
"id": 1303,
4+
"name": "Stardew Valley",
5+
"name_lower": "stardew valley",
6+
"forum_url": "https://forums.nexusmods.com/games/19-stardew-valley/",
7+
"nexusmods_url": "https://www.nexusmods.com/stardewvalley",
8+
"genre": "Simulation",
9+
"file_count": 137612,
10+
"downloads": 592183501,
11+
"domain_name": "stardewvalley",
12+
"approved_date": 1457432329,
13+
"mods": 24655,
14+
"collections": 3570
15+
},
16+
{
17+
"id": 3174,
18+
"name": "Mount & Blade II: Bannerlord",
19+
"name_lower": "mount & blade ii: bannerlord",
20+
"forum_url": "https://forums.nexusmods.com/games/9-mount-blade-ii-bannerlord/",
21+
"nexusmods_url": "https://www.nexusmods.com/mountandblade2bannerlord",
22+
"genre": "Strategy",
23+
"file_count": 49182,
24+
"downloads": 111421397,
25+
"domain_name": "mountandblade2bannerlord",
26+
"approved_date": 1582898627,
27+
"mods": 6136,
28+
"collections": 321
29+
},
30+
{
31+
"id": 3333,
32+
"name": "Cyberpunk 2077",
33+
"name_lower": "cyberpunk 2077",
34+
"forum_url": "https://forums.nexusmods.com/games/1-cyberpunk-2077/",
35+
"nexusmods_url": "https://www.nexusmods.com/cyberpunk2077",
36+
"genre": "Action",
37+
"file_count": 118327,
38+
"downloads": 825382927,
39+
"domain_name": "cyberpunk2077",
40+
"approved_date": 1607433331,
41+
"mods": 16707,
42+
"collections": 1910
43+
},
44+
{
45+
"id": 3474,
46+
"name": "Baldur's Gate 3",
47+
"name_lower": "baldur's gate 3",
48+
"forum_url": "https://forums.nexusmods.com/games/2-baldurs-gate-3/",
49+
"nexusmods_url": "https://www.nexusmods.com/baldursgate3",
50+
"genre": "RPG",
51+
"file_count": 100954,
52+
"downloads": 325304689,
53+
"domain_name": "baldursgate3",
54+
"approved_date": 1602863114,
55+
"mods": 14186,
56+
"collections": 3703
57+
}
58+
]
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env nix-shell
2+
#! nix-shell -i bash -p bash curl jq
3+
4+
set -eu -o pipefail
5+
6+
url='https://data.nexusmods.com/file/nexus-data/games.json'
7+
self=$(realpath "$0")
8+
dir=$(dirname "$self")
9+
tmp=$(mktemp)
10+
11+
cd "$dir"/../../../../../
12+
13+
ids=$(
14+
nix-instantiate --eval --json \
15+
--argstr file "$dir"/game-ids.nix \
16+
--expr '{file}: builtins.attrValues (import file)'
17+
)
18+
19+
echo "Fetching games data" >&2
20+
curl "$url" \
21+
--silent \
22+
--show-error \
23+
--location |
24+
jq --argjson ids "$ids" \
25+
'map(select( .id | IN($ids[]) )) | sort_by(.id)' \
26+
>"$tmp"
27+
28+
echo "Validating result" >&2
29+
nix-instantiate --eval --strict \
30+
--argstr idsNix "$dir"/game-ids.nix \
31+
--argstr gamesJson "$tmp" \
32+
--expr '
33+
{
34+
idsNix,
35+
gamesJson,
36+
lib ? import <nixpkgs/lib>,
37+
}:
38+
let
39+
ids = import idsNix;
40+
games = lib.importJSON gamesJson;
41+
in
42+
lib.forEach games (
43+
{ id, name, ... }:
44+
lib.throwIfNot
45+
(id == ids.${name})
46+
"${name}: id ${toString id} does not match ${toString ids.${name}}"
47+
null
48+
)
49+
' \
50+
>/dev/null
51+
52+
echo "Installing games.json to $dir" >&2
53+
mv --force "$tmp" "$dir"/games.json

0 commit comments

Comments
 (0)