OpenRCT2: Allow Overriding Asset Sources (#527361)

This commit is contained in:
Peder Bergebakken Sundt
2026-07-13 22:13:55 +00:00
committed by GitHub
+45 -46
View File
@@ -32,40 +32,22 @@
speexdsp,
versionCheckHook,
zlib,
zstd,
withDiscordRpc ? false,
verifyAssets ? true,
# Paths to RCT1 and RCT2 installs can be specified to have them added as a wrapped argument
rct1Path ? null,
rct2Path ? null,
}:
let
objects-version = "1.7.10";
openmusic-version = "1.6.1";
opensfx-version = "1.0.6";
title-sequences-version = "0.4.26";
objects = fetchurl {
url = "https://github.com/OpenRCT2/objects/releases/download/v${objects-version}/objects.zip";
hash = "sha256-9IO+Jm3CIHe6hRe78y/+OIw1Q7LuWF4K+9QQLbRSgCE=";
};
openmusic = fetchurl {
url = "https://github.com/OpenRCT2/OpenMusic/releases/download/v${openmusic-version}/openmusic.zip";
hash = "sha256-mUs1DTsYDuHLlhn+J/frrjoaUjKEDEvUeonzP6id4aE=";
};
opensfx = fetchurl {
url = "https://github.com/OpenRCT2/OpenSoundEffects/releases/download/v${opensfx-version}/opensound.zip";
hash = "sha256-BrkPPhnCFnUt9EHVUbJqnj4bp3Vb3SECUEtzv5k2CL4=";
};
title-sequences = fetchurl {
url = "https://github.com/OpenRCT2/title-sequences/releases/download/v${title-sequences-version}/title-sequences.zip";
hash = "sha256-2ruXh7FXY0L8pN2fZLP4z6BKfmzpwruWEPR7dikFyFg=";
};
in
stdenv.mkDerivation (finalAttrs: {
pname = "openrct2";
version = "0.5.3";
__structuredAttrs = true;
strictDeps = true;
src = fetchFromGitHub {
owner = "OpenRCT2";
repo = "OpenRCT2";
@@ -73,6 +55,34 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-my7fPBD5N0bO1yPaxwHUFqw6TvayQs10kcAX/NqPpIg=";
};
passthru = {
updateScript = ./update.sh;
objects-version = "1.7.10";
openmusic-version = "1.6.1";
opensfx-version = "1.0.6";
title-sequences-version = "0.4.26";
assets = {
objects = fetchurl {
url = "https://github.com/OpenRCT2/objects/releases/download/v${finalAttrs.passthru.objects-version}/objects.zip";
hash = "sha256-9IO+Jm3CIHe6hRe78y/+OIw1Q7LuWF4K+9QQLbRSgCE=";
};
openmusic = fetchurl {
url = "https://github.com/OpenRCT2/OpenMusic/releases/download/v${finalAttrs.passthru.openmusic-version}/openmusic.zip";
hash = "sha256-mUs1DTsYDuHLlhn+J/frrjoaUjKEDEvUeonzP6id4aE=";
};
opensfx = fetchurl {
url = "https://github.com/OpenRCT2/OpenSoundEffects/releases/download/v${finalAttrs.passthru.opensfx-version}/opensound.zip";
hash = "sha256-BrkPPhnCFnUt9EHVUbJqnj4bp3Vb3SECUEtzv5k2CL4=";
};
title-sequences = fetchurl {
url = "https://github.com/OpenRCT2/title-sequences/releases/download/v${finalAttrs.passthru.title-sequences-version}/title-sequences.zip";
hash = "sha256-2ruXh7FXY0L8pN2fZLP4z6BKfmzpwruWEPR7dikFyFg=";
};
};
};
nativeBuildInputs = [
cmake
pkg-config
@@ -104,6 +114,7 @@ stdenv.mkDerivation (finalAttrs: {
openssl
speexdsp
zlib
zstd
]
++ lib.optional withDiscordRpc discord-rpc;
@@ -117,31 +128,21 @@ stdenv.mkDerivation (finalAttrs: {
postUnpack = ''
mkdir -p $sourceRoot/data/{object,sequence}
unzip -o ${objects} -d $sourceRoot/data/object
unzip -o ${openmusic} -d $sourceRoot/data
unzip -o ${opensfx} -d $sourceRoot/data
unzip -o ${title-sequences} -d $sourceRoot/data/sequence
'';
# Fix blank changelog & contributors screen. See https://github.com/OpenRCT2/OpenRCT2/issues/16988
postPatch = ''
substituteInPlace src/openrct2/platform/Platform.Linux.cpp \
--replace-fail "/usr/share/doc/openrct2" "$out/share/doc/openrct2"
unzip -o ${finalAttrs.passthru.assets.objects} -d $sourceRoot/data/object
unzip -o ${finalAttrs.passthru.assets.openmusic} -d $sourceRoot/data
unzip -o ${finalAttrs.passthru.assets.opensfx} -d $sourceRoot/data
unzip -o ${finalAttrs.passthru.assets.title-sequences} -d $sourceRoot/data/sequence
'';
preConfigure =
# Verify that the correct version of each third party repository is used.
(
let
versionCheck = assetKey: url: ''
grep -qF '"${url}"' assets.json \
|| (echo "${assetKey} differs from expected version!"; exit 1)
'';
in
(versionCheck "objects" objects.url)
+ (versionCheck "openmusic" openmusic.url)
+ (versionCheck "opensfx" opensfx.url)
+ (versionCheck "title-sequences" title-sequences.url)
lib.optionalString verifyAssets (
lib.concatStringsSep "\n" (
lib.mapAttrsToList (assetName: asset: ''
grep -qF '"${asset.url}"' assets.json \
|| (echo "${assetName} differs from expected version!"; exit 1)
'') finalAttrs.passthru.assets
)
);
doInstallCheck = true;
@@ -152,8 +153,6 @@ stdenv.mkDerivation (finalAttrs: {
${lib.optionalString (rct2Path != null) "--add-flags '--rct2-data-path=\"${rct2Path}\"'"}
'';
passthru.updateScript = ./update.sh;
meta = {
description = "Open source re-implementation of RollerCoaster Tycoon 2";
longDescription = ''