Skip to content

Open-source Xbox-inspired desktop launcher for Xodus on Linux

TypeScript

feat(proton): carry verified launch context and payload features

Nexus Maintainerbdc7279b231a
diff --git a/src/main/game-wrapper.test.ts b/src/main/game-wrapper.test.ts
index 2fc912f..549186b 100644
--- a/src/main/game-wrapper.test.ts
+++ b/src/main/game-wrapper.test.ts
@@ -79,6 +79,29 @@ it('supports MangoHud directly and gamescope with mangoapp, never wrapping a lau
expect(result.output).not.toContain('\nMANGO\n'); expect(result.code).toBe(7);
expect(await readFile(scope.command,'utf8')).not.toContain('xodus-cli');
});
+it('passes a Proton compat-config launch option as literal data and never evaluates it', async () => {
+ const { root, wine, env } = await setup();
+ const marker = path.join(root, 'executed-by-a-shell');
+ await writeFile(wine, '#!/bin/sh\nprintf "config=<%s>\\n" "$STEAM_COMPAT_CONFIG"\nprintf "arg=<%s>\\n" "$@"; exit 7');
+ const value = `cmdlineappend:--flag=$(touch ${marker}) \`touch ${marker}\`;x,wined3d`;
+ const wrapper = await prepareGameWrapper(wine, { ...defaultLaunchTools,
+ launchOptions: `STEAM_COMPAT_CONFIG="${value}" %command%` }, path.join(root, 'wrappers'), env);
+ const result = await run(wrapper.command, ['game.exe'], { env });
+ expect(result.code).toBe(7);
+ expect(result.output).toContain(`config=<${value}>`);
+ expect(result.output).toContain('arg=<game.exe>');
+ // The assignment was not interpreted by a shell: only the literal value
+ // reached the command environment and no attempt was made to run its content.
+ expect(await readFile(wrapper.command, 'utf8')).toContain("'STEAM_COMPAT_CONFIG=");
+ await expect(stat(marker)).rejects.toThrow();
+ // The same rule holds for a value that itself contains a single quote.
+ const quoted = "cmdlineappend:it's,localshadercache";
+ const second = await prepareGameWrapper(wine, { ...defaultLaunchTools,
+ launchOptions: `STEAM_COMPAT_CONFIG="${quoted}" %command%` }, path.join(root, 'other'), env);
+ expect((await run(second.command, ['game.exe'], { env })).output).toContain(`config=<${quoted}>`);
+ await wrapper.cleanup(); await second.cleanup();
+});
+
it('fails clearly before starting a configured missing tool',async()=>{
const {root,wine}=await setup();
await expect(prepareGameWrapper(wine,{...defaultLaunchTools,mangoHud:true},path.join(root,'wrappers'),{PATH:root})).rejects.toThrow('mangohud');
diff --git a/src/main/index.ts b/src/main/index.ts
index b8b3546..53d5ced 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -41,7 +41,7 @@ import { inspectGameDirectory, StateStore } from './store.js';
import { inspectStartupLibrary } from './startup-library.js';
import { hasIncompleteUpdate, INCOMPLETE_UPDATE_MESSAGE } from './installation-state.js';
import { RuntimeManager, type RuntimeSettingsReservation } from './runtime.js';
-import { prepareProtonRunner, protonOptionalComponentNotices, syncPrefixUserLocale, syncUnrealCultureGameIni } from './proton.js';
+import { prepareProtonRunner, protonLaunchFeatureNotices, protonOptionalComponentNotices, syncPrefixUserLocale, syncUnrealCultureGameIni } from './proton.js';
import { layoutOfWine } from './proton-layout.js';
import { accountCacheKey } from './offline-identity.js';
import { applyOfflinePermissions, assertOfflineAccessReady, bindOfflineAccess, licenseCacheDirectory, offlineAccessRevoked, revokeOfflineAccess, type OfflineRevocation } from './offline-access.js';
@@ -1387,7 +1387,7 @@ async function prepareGameLaunch(id: string, steam?: SteamGameContext): Promise<
const legacyPrefixRoot = runtimeContext.legacyPrefixRoot;
const compatibilityDataPath = runtimeContext.compatibilityDataPath;
const steamRoot = path.join(app.getPath('home'), '.steam', 'root');
- const protonRunner = await prepareProtonRunner(wine, compatibilityDataPath, steamRoot, store.settings.shaderCacheLimitGiB);
+ const protonRunner = await prepareProtonRunner(wine, compatibilityDataPath, steamRoot, store.settings.shaderCacheLimitGiB, { installPath: game.path });
const wineCommand = protonRunner?.command ?? wine;
// Play goes through the runtime's Proton session when one is available, so
// the runtime's own launch options (for example PROTON_USE_OPTISCALER) are
@@ -1401,6 +1401,10 @@ async function prepareGameLaunch(id: string, steam?: SteamGameContext): Promise<
const launchOptionsEnvironment = parseLaunchOptions(game.launchTools?.launchOptions ?? '').environment;
for (const notice of await protonOptionalComponentNotices({ ...launchEnvironment, ...launchOptionsEnvironment },
protonRunner.protonRoot, compatibilityDataPath, offlineLaunch)) addGameLog(notice);
+ // Options that need a Steam game id or the runtime's umu/Steam helper are
+ // reported as inactive instead of being simulated with an invented id.
+ for (const notice of await protonLaunchFeatureNotices({ ...launchEnvironment, ...launchOptionsEnvironment },
+ protonRunner.protonRoot, protonRunner.compatibilityLocation)) addGameLog(notice);
}
if (inspected.vcRedistEncrypted) {
if (!protonRunner) throw new Error('This encrypted VC++ prerequisite requires a Proton prefix. Select Xodus Runtime in Settings.');
diff --git a/src/main/proton-launch-features.test.ts b/src/main/proton-launch-features.test.ts
new file mode 100644
index 0000000..6e06ec9
--- /dev/null
+++ b/src/main/proton-launch-features.test.ts
@@ -0,0 +1,198 @@
+import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
+import { tmpdir } from 'node:os';
+import path from 'node:path';
+import { afterEach, describe, expect, it } from 'vitest';
+import { protonLaunchFeatureNotices } from './proton.js';
+import { acceptSteamHandoff, captureSteamLaunchEnvironment, offerSteamHandoff, steamGameEnvironment, steamHandoffRequest } from './steam-launch-context.js';
+
+const created: string[] = [];
+const offers: { close(): void }[] = [];
+const leases: { close(): void }[] = [];
+
+afterEach(async () => {
+ for (const lease of leases.splice(0)) lease.close();
+ for (const offer of offers.splice(0)) offer.close();
+ await Promise.all(created.splice(0).map((directory) => rm(directory, { recursive: true, force: true })));
+});
+
+/**
+ * A runtime root is the only thing these notices inspect. Neither family is
+ * emulated beyond the reviewed capability files: protonfixes for the CachyOS
+ * feature set and the native Discord bridge payload.
+ */
+async function runtime(options: { protonfixes?: boolean; discordBridge?: boolean } = {}): Promise<string> {
+ const root = await mkdtemp(path.join(tmpdir(), 'nexus-proton-features-')); created.push(root);
+ if (options.protonfixes) {
+ await mkdir(path.join(root, 'protonfixes'), { recursive: true });
+ await writeFile(path.join(root, 'protonfixes', 'utilities.py'), 'fixture');
+ }
+ if (options.discordBridge) {
+ await mkdir(path.join(root, 'files', 'lib', 'wine', 'discord-rpc-bridge'), { recursive: true });
+ await writeFile(path.join(root, 'files', 'lib', 'wine', 'discord-rpc-bridge', 'bridge.exe'), 'fixture');
+ }
+ return root;
+}
+
+/** A notice must never claim that a feature Nexus cannot serve is working. */
+function expectNoPositiveClaim(notices: string[]): void {
+ for (const notice of notices) expect(notice).not.toMatch(/is active|has been started|will be started|is enabled/i);
+}
+
+describe('protonLaunchFeatureNotices', () => {
+ it.each([undefined, '', '0'])('stays silent for an unrequested option (%j)', async (value) => {
+ const root = await runtime();
+ const environment = {
+ PROTON_DISCORD_BRIDGE: value, PROTON_LOCAL_SHADER_CACHE: value, PROTON_LOG: value, PROTON_SET_GAME_DRIVE: value,
+ } as Record<string, string | undefined>;
+ expect(await protonLaunchFeatureNotices(environment, root)).toEqual([]);
+ });
+
+ it('reports unsupported context-dependent options of a runtime without them', async () => {
+ const root = await runtime();
+ const notices = await protonLaunchFeatureNotices({
+ PROTON_LOCAL_SHADER_CACHE: '1', PROTON_DISCORD_BRIDGE: '1', PROTON_LOG: '1', PROTON_SET_GAME_DRIVE: '1',
+ }, root);
+ expect(notices).toHaveLength(4);
+ expect(notices[0]).toContain('does not include the Discord RPC bridge');
+ expect(notices[0]).toContain('no effect');
+ expect(notices[1]).toContain('PROTON_LOCAL_SHADER_CACHE');
+ expect(notices[1]).toContain('does not implement it');
+ expect(notices[2]).toContain('Steam game id');
+ expect(notices[2]).toContain('Wine and DXVK logging');
+ expect(notices[3]).toContain('S: game drive');
+ expect(notices[3]).toContain('Steam library');
+ expect(notices[3]).toContain('does not fabricate one');
+ expectNoPositiveClaim(notices);
+ });
+
+ // The S: drive is created by Proton only from a real `steamapps` library, so
+ // the notice follows the verified location context of this launch. A genuinely
+ // mapped library must never be reported as inactive, and vice versa.
+ const plainLocation = { installPath: '/games/Game' };
+ const libraryLocation = { installPath: '/steam-library/steamapps/common/Game', libraryPaths: '/steam-library/steamapps' };
+
+ it('warns about the S: game drive only when the launch has no verified Steam library', async () => {
+ const root = await runtime();
+ const environment = { PROTON_SET_GAME_DRIVE: '1' };
+ // No captured location at all, and a captured plain Nexus install.
+ for (const location of [undefined, plainLocation]) {
+ const notices = await protonLaunchFeatureNotices(environment, root, location);
+ expect(notices).toHaveLength(1);
+ expect(notices[0]).toContain('not installed inside a verified Steam library');
+ expect(notices[0]).toContain('S: game drive');
+ expectNoPositiveClaim(notices);
+ }
+ // A real Steam library is mapped by Proton: no negative claim at all.
+ expect(await protonLaunchFeatureNotices(environment, root, libraryLocation)).toEqual([]);
+ // An explicit disabled request is not a request, with any location.
+ for (const value of ['0', '']) {
+ for (const location of [undefined, plainLocation, libraryLocation]) {
+ expect(await protonLaunchFeatureNotices({ PROTON_SET_GAME_DRIVE: value }, root, location)).toEqual([]);
+ }
+ }
+ });
+
+ it.each([
+ ['Standard', {}],
+ ['CachyOS', { protonfixes: true, discordBridge: true }],
+ ])('uses the verified location context for %s runtimes', async (_family, options) => {
+ const root = await runtime(options);
+ // Other requested options are independent of the location context.
+ const requested = { PROTON_SET_GAME_DRIVE: '1', PROTON_LOG: '1' };
+ const plain = await protonLaunchFeatureNotices(requested, root, plainLocation);
+ expect(plain).toHaveLength(2);
+ expect(plain[1]).toContain('not installed inside a verified Steam library');
+ const mapped = await protonLaunchFeatureNotices(requested, root, libraryLocation);
+ expect(mapped).toHaveLength(1);
+ expect(mapped[0]).toContain('PROTON_LOG');
+ expect(mapped.join(' ')).not.toContain('S: game drive');
+ });
+
+ it('accepts the local shader cache when the runtime implements it and keeps the bridge inactive', async () => {
+ const root = await runtime({ protonfixes: true, discordBridge: true });
+ // The CachyOS feature set implements local shader caches through protonfixes.
+ expect(await protonLaunchFeatureNotices({ PROTON_LOCAL_SHADER_CACHE: '1' }, root)).toEqual([]);
+ // The bridge payload alone is not a running service: only the runtime's
+ // umu/Steam helper starts it, and this launch path does not use that helper.
+ const notices = await protonLaunchFeatureNotices({ PROTON_DISCORD_BRIDGE: '1' }, root);
+ expect(notices).toHaveLength(1);
+ expect(notices[0]).toContain('Discord RPC bridge is installed');
+ expect(notices[0]).toContain('helper');
+ expect(notices[0]).toContain('does not start the bridge');
+ expect(notices[0]).toContain('inactive');
+ // The reason is the direct Proton session launch, not a missing identity.
+ expect(notices[0]).not.toContain('Steam game id');
+ expectNoPositiveClaim(notices);
+ });
+
+ // Pinned setup_logging creates the Proton log file when the effective
+ // environment carries a Steam game id (key presence, not the value). The
+ // notice must follow that and never claim the launch has no id when a genuine
+ // Steam shortcut handoff forwarded one.
+ it('reports PROTON_LOG only when the effective environment has no Steam game id', async () => {
+ const root = await runtime();
+ for (const steamGameId of ['16968485195965530112', '0', '']) {
+ const forwarded = steamGameEnvironment({ HOME: '/home/test' }, { SteamGameId: steamGameId });
+ expect(forwarded.SteamGameId).toBe(steamGameId);
+ expect(await protonLaunchFeatureNotices({ ...forwarded, PROTON_LOG: '1' }, root)).toEqual([]);
+ }
+ // Ambient presence satisfies the pinned check exactly like a handoff does.
+ expect(await protonLaunchFeatureNotices({ SteamGameId: '123', PROTON_LOG: '1' }, root)).toEqual([]);
+ const notices = await protonLaunchFeatureNotices({ PROTON_LOG: '1' }, root);
+ expect(notices).toHaveLength(1);
+ expect(notices[0]).toContain('Steam game id');
+ expect(notices[0]).toContain('Wine and DXVK logging');
+ // No log path or identifier leaks into the notice.
+ expect(notices[0]).not.toContain('steam-');
+ expect(notices[0]).not.toContain('16968485195965530112');
+ // An explicit disabled value is not a request in either context.
+ for (const value of ['0', '']) {
+ for (const environment of [{}, { SteamGameId: '16968485195965530112' }]) {
+ expect(await protonLaunchFeatureNotices({ ...environment, PROTON_LOG: value }, root)).toEqual([]);
+ }
+ }
+ });
+
+ it('honours a forwarded authenticated Steam shortcut environment in the notices', async () => {
+ const root = await runtime({ protonfixes: true, discordBridge: true });
+ const captured = captureSteamLaunchEnvironment({
+ SteamGameId: '16968485195965530112',
+ SteamAppId: '16968485195965530112',
+ SDL_GAMECONTROLLERCONFIG: 'Xbox mapping',
+ });
+ expect(captured).toBeDefined();
+ const offer = offerSteamHandoff(captured!, () => {});
+ offers.push(offer);
+ // The launcher receives the handoff as IPC data and authenticates its lease.
+ const request = steamHandoffRequest(JSON.parse(JSON.stringify({ nexusSteam: offer.handoff })))!;
+ const lease = await acceptSteamHandoff(request);
+ leases.push(lease);
+ expect(request.lease.token).toMatch(/^[a-f0-9]{64}$/);
+ // A wrong lease token is still rejected, so this is the authenticated path.
+ await expect(acceptSteamHandoff({ ...request, lease: { ...request.lease, token: '0'.repeat(64) } }))
+ .rejects.toThrow();
+ const forwarded = steamGameEnvironment({ HOME: '/home/test' }, captured);
+ expect(forwarded.SteamGameId).toBe('16968485195965530112');
+ expect(forwarded.SDL_GAMECONTROLLERCONFIG).toBe('Xbox mapping');
+ const notices = await protonLaunchFeatureNotices({ ...forwarded, PROTON_LOG: '1', PROTON_DISCORD_BRIDGE: '1' }, root);
+ // Logging works in this genuine Steam context, so no no-log claim appears.
+ expect(notices).toHaveLength(1);
+ expect(notices[0]).toContain('PROTON_DISCORD_BRIDGE');
+ expect(notices[0]).toContain('does not start the bridge');
+ expect(notices.join(' ')).not.toContain('Steam game id');
+ });
+
+ it('follows Proton nonzero semantics for whitespace-only values', async () => {
+ const root = await runtime();
+ // Upstream only treats an empty or literal "0" value as disabled.
+ expect(await protonLaunchFeatureNotices({ PROTON_DISCORD_BRIDGE: ' ' }, root)).toHaveLength(1);
+ expect(await protonLaunchFeatureNotices({ PROTON_DISCORD_BRIDGE: '0' }, root)).toEqual([]);
+ });
+
+ it('does not throw or overclaim for a runtime that is not a Proton payload', async () => {
+ const root = await runtime();
+ const notices = await protonLaunchFeatureNotices({ PROTON_DISCORD_BRIDGE: '1' }, path.join(root, 'absent'));
+ expect(notices).toHaveLength(1);
+ expect(notices[0]).toContain('no effect');
+ });
+});
diff --git a/src/main/proton-pinned-source.test.ts b/src/main/proton-pinned-source.test.ts
new file mode 100644
index 0000000..5b87d73
--- /dev/null
+++ b/src/main/proton-pinned-source.test.ts
@@ -0,0 +1,226 @@
+import { execFile as execFileCallback } from 'node:child_process';
+import { mkdir, mkdtemp, realpath, rm, writeFile } from 'node:fs/promises';
+import { tmpdir } from 'node:os';
+import path from 'node:path';
+import { promisify } from 'node:util';
+import { afterAll, describe, expect, it } from 'vitest';
+import { prepareProtonRunner, protonLaunchFeatureNotices } from './proton.js';
+import { prepareGameWrapper } from './game-wrapper.js';
+import { defaultLaunchTools } from '../shared/launch-tools.js';
+
+// Executes the PINNED runtime source read-only under python3. No Wine, Proton,
+// game or network process is involved; the extracted functions only read the
+// environment and the fixture prefix. Skip unless the source file is provided:
+// XODUS_PROTON_SOURCE=/path/to/the/pinned/proton
+const protonSource = process.env.XODUS_PROTON_SOURCE;
+const created: string[] = [];
+const execFile = promisify(execFileCallback);
+
+afterAll(async () => {
+ await Promise.all(created.splice(0).map((directory) => rm(directory, { recursive: true, force: true })));
+});
+
+/**
+ * Extracts the reviewed selectors from the pinned entry script and applies them
+ * to the environment the production Play command exports. Nothing else from
+ * the script is imported or executed, so no session, prefix or Wine setup runs.
+ */
+const probe = String.raw`
+import json, os, sys, textwrap
+
+source_lines = open(sys.argv[1], encoding='utf-8').read().splitlines()
+mode = sys.argv[2]
+
+def block(header, indent=8):
+ for index, line in enumerate(source_lines):
+ if line.strip() == header and len(line) - len(line.lstrip()) == indent:
+ out = [line]
+ for follow in source_lines[index + 1:]:
+ if not follow.strip():
+ out.append(follow)
+ continue
+ if len(follow) - len(follow.lstrip()) <= indent:
+ break
+ out.append(follow)
+ return textwrap.dedent('\n'.join(out))
+ raise SystemExit('missing block: ' + header)
+
+def function(name):
+ for index, line in enumerate(source_lines):
+ if line.startswith('def ' + name + '('):
+ out = [line]
+ for follow in source_lines[index + 1:]:
+ if follow and not follow.startswith((' ', '\t')):
+ break
+ out.append(follow)
+ return '\n'.join(out).rstrip()
+ raise SystemExit('missing function: ' + name)
+
+def method(name, indent=4):
+ for index, line in enumerate(source_lines):
+ if len(line) - len(line.lstrip()) == indent and line.lstrip().startswith('def ' + name + '('):
+ out = [line]
+ for follow in source_lines[index + 1:]:
+ if follow.strip() and len(follow) - len(follow.lstrip()) <= indent:
+ break
+ out.append(follow)
+ return textwrap.dedent('\n'.join(out)).rstrip()
+ raise SystemExit('missing method: ' + name)
+
+if mode == 'config':
+ namespace = {'os': os}
+ exec(function('comma_escaped'), namespace)
+ session = type('Session', (), {})()
+ session.compat_config = set()
+ session.cmdlineappend = []
+ namespace['self'] = session
+ exec(block('if "STEAM_COMPAT_CONFIG" in os.environ:'), namespace)
+ print(json.dumps({'compat_config': sorted(session.compat_config), 'cmdlineappend': session.cmdlineappend}))
+elif mode == 'drive':
+ def file_exists(value, follow_symlinks=True):
+ return os.path.exists(value) if follow_symlinks else os.path.lexists(value)
+ def log(*args, **kwargs):
+ pass
+ namespace = {'os': os, 'log': log, 'file_exists': file_exists}
+ for name in ['get_validated_steamapps_parent', 'try_get_game_library_dir', 'setup_dir_drive', 'setup_game_dir_drive']:
+ exec(function(name), namespace)
+ session = type('Session', (), {})()
+ session.env = dict(os.environ)
+ # The pinned session adds the gamedrive compat option by default in
+ # CachyOS and through PROTON_SET_GAME_DRIVE in Standard. The location
+ # mapping below is what the launcher feeds; it never adds this option.
+ session.compat_config = {'gamedrive'}
+ compatdata = type('CompatData', (), {})()
+ compatdata.prefix_dir = os.environ['WINEPREFIX'] + '/'
+ namespace['g_session'] = session
+ namespace['g_compatdata'] = compatdata
+ # A real Proton prefix already has dosdevices; this fixture prefix does not.
+ os.makedirs(os.path.join(compatdata.prefix_dir, 'dosdevices'), exist_ok=True)
+ namespace['setup_game_dir_drive']()
+ link = os.path.join(compatdata.prefix_dir, 'dosdevices', 's:')
+ print(json.dumps({'game_drive': os.readlink(link) if os.path.islink(link) else None}))
+elif mode == 'logging':
+ def file_exists(value, follow_symlinks=True):
+ return os.path.exists(value) if follow_symlinks else os.path.lexists(value)
+ def makedirs(dir_path):
+ os.makedirs(dir_path, exist_ok=True)
+ namespace = {'os': os, 'file_exists': file_exists, 'makedirs': makedirs}
+ exec(method('setup_logging'), namespace)
+ # The pinned CachyOS variant reads the runtime version file for an optional
+ # suffix; a missing file is its own documented fallback to no suffix.
+ proton = type('Proton', (), {})()
+ proton.version_file = os.environ.get('NEXUS_PROBE_VERSION_FILE', os.path.join(os.environ['HOME'], 'absent-version'))
+ namespace['g_proton'] = proton
+ session = type('Session', (), {})()
+ session.env = dict(os.environ)
+ configured = os.environ.get('PROTON_LOG')
+ invoked = configured is not None and len(configured) > 0 and configured != '0'
+ created = bool(namespace['setup_logging'](session, append_forever=False)) if invoked else False
+ log = getattr(session, 'log_file', None)
+ name = os.path.basename(log.name) if log is not None else None
+ if log is not None:
+ log.close()
+ print(json.dumps({'invoked': invoked, 'created': created, 'name': name}))
+else:
+ raise SystemExit('unknown mode: ' + mode)
+`;
+
+interface Fixture {
+ root: string;
+ wine: string;
+ compat: string;
+ install: string;
+}
+
+async function fixture(mode: string, installPath?: string): Promise<Fixture> {
+ const root = await mkdtemp(path.join(tmpdir(), `nexus-pinned-${mode}-`)); created.push(root);
+ const files = path.join(root, 'runtime/files');
+ const wine = path.join(files, 'bin/wine'), proton = path.join(root, 'runtime/proton');
+ const compat = path.join(root, 'compat'), system32 = path.join(compat, 'pfx/drive_c/windows/system32');
+ const install = installPath ?? path.join(root, 'installs/Game');
+ await mkdir(path.dirname(wine), { recursive: true });
+ await mkdir(path.join(files, 'share/default_pfx'), { recursive: true });
+ await mkdir(system32, { recursive: true });
+ for (const name of ['libvkd3d-utils-1.dll', 'dxgi.dll', 'd3d12.dll']) await writeFile(path.join(system32, name), 'fixture');
+ await writeFile(wine, '#!/bin/sh\nexit 0\n', { mode: 0o700 });
+ await writeFile(path.join(files, 'bin/wineserver'), '#!/bin/sh\nexit 0\n', { mode: 0o700 });
+ const script = path.join(root, 'probe.py');
+ await writeFile(script, probe);
+ // The fixture Proton session only forwards the Play arguments to the probe,
+ // which applies the exact pinned selector to the inherited environment.
+ const quote = (value: string) => `'${value.replaceAll("'", `'"'"'`)}'`;
+ await writeFile(proton, `#!/bin/sh\n[ "$1" = run ] || exit 0\nshift\nexec python3 ${quote(script)} ${quote(protonSource!)} ${quote(mode)} "$@"\n`, { mode: 0o700 });
+ return { root, wine, compat, install };
+}
+
+describe.skipIf(!protonSource)('pinned Proton selectors', () => {
+ it('parses a compat-config launch option with the pinned runtime parser', async () => {
+ const f = await fixture('config'), runner = (await prepareProtonRunner(f.wine, f.compat, path.join(f.root, 'steam')))!;
+ // Proton appends each cmdlineappend entry as one argv element and only adds
+ // the remaining names to its compat config.
+ const value = 'cmdlineappend:--flag one\\,two,wined3d,localshadercache';
+ const wrapper = await prepareGameWrapper(runner.launchCommand, { ...defaultLaunchTools,
+ launchOptions: `STEAM_COMPAT_CONFIG='${value}' %command%` }, path.join(f.root, 'wrappers'), process.env);
+ const { stdout } = await execFile(wrapper.command, ['Z:\\game\\Game.exe'], { env: process.env });
+ const parsed = JSON.parse(stdout.trim().split('\n').pop()!);
+ expect(parsed).toEqual({ compat_config: ['localshadercache', 'wined3d'], cmdlineappend: ['--flag one,two'] });
+ // Empty, literal zero and whitespace-only values stay data and add no option.
+ for (const [configured, expected] of [
+ ['', { compat_config: [], cmdlineappend: [] }],
+ ['0', { compat_config: ['0'], cmdlineappend: [] }],
+ [' ', { compat_config: [' '], cmdlineappend: [] }],
+ ] as const) {
+ const empty = await prepareGameWrapper(runner.launchCommand, { ...defaultLaunchTools,
+ launchOptions: `STEAM_COMPAT_CONFIG='${configured}' %command%` }, path.join(f.root, `wrappers-${configured.length ? 'data' : 'empty'}`), process.env);
+ const result = JSON.parse((await execFile(empty.command, ['Z:\\game\\Game.exe'], { env: process.env })).stdout.trim().split('\n').pop()!);
+ expect(result).toEqual(expected);
+ await empty.cleanup();
+ }
+ await wrapper.cleanup();
+ }, 60_000);
+
+ it('matches the pinned logging selector for a Steam launch environment', async () => {
+ const f = await fixture('logging');
+ const logs = path.join(f.root, 'logs'); await mkdir(logs, { recursive: true });
+ const pinned = async (extra: NodeJS.ProcessEnv) => {
+ const env: NodeJS.ProcessEnv = { ...process.env, HOME: logs };
+ for (const name of ['SteamGameId', 'PROTON_LOG', 'PROTON_LOG_DIR', 'NEXUS_PROBE_VERSION_FILE']) delete env[name];
+ const { stdout } = await execFile('python3', [path.join(f.root, 'probe.py'), protonSource!, 'logging'],
+ { env: { ...env, ...extra } });
+ return JSON.parse(stdout.trim().split('\n').pop()!);
+ };
+ // No Steam game id: the pinned function returns before creating a file.
+ expect(await pinned({ PROTON_LOG: '1' })).toEqual({ invoked: true, created: false, name: null });
+ expect(await protonLaunchFeatureNotices({ PROTON_LOG: '1' }, f.root)).toHaveLength(1);
+ // A forwarded Steam game id lets the pinned function create its log file.
+ expect(await pinned({ PROTON_LOG: '1', SteamGameId: '16968485195965530112' }))
+ .toEqual({ invoked: true, created: true, name: 'steam-16968485195965530112.log' });
+ expect(await protonLaunchFeatureNotices({ PROTON_LOG: '1', SteamGameId: '16968485195965530112' }, f.root)).toEqual([]);
+ // Presence semantics: an empty value still satisfies the pinned check.
+ expect(await pinned({ PROTON_LOG: '1', SteamGameId: '' }))
+ .toEqual({ invoked: true, created: true, name: 'steam-.log' });
+ expect(await protonLaunchFeatureNotices({ PROTON_LOG: '1', SteamGameId: '' }, f.root)).toEqual([]);
+ // The caller nonzero gate still decides whether logging is set up at all.
+ for (const value of ['0', '']) {
+ expect(await pinned({ PROTON_LOG: value })).toEqual({ invoked: false, created: false, name: null });
+ expect(await protonLaunchFeatureNotices({ PROTON_LOG: value }, f.root)).toEqual([]);
+ }
+ }, 60_000);
+
+ it('maps the game drive from the verified install location with the pinned runtime functions', async () => {
+ const plain = await fixture('drive');
+ await mkdir(plain.install, { recursive: true });
+ const plainRunner = (await prepareProtonRunner(plain.wine, plain.compat, path.join(plain.root, 'steam'), 4, { installPath: plain.install }))!;
+ const plainResult = JSON.parse((await execFile(plainRunner.launchCommand, ['Z:\\game\\Game.exe'], { env: process.env })).stdout.trim().split('\n').pop()!);
+ // A Nexus installation outside a Steam library has no game library drive.
+ expect(plainResult).toEqual({ game_drive: null });
+ // A game genuinely inside a Steam library reports that library.
+ const library = await fixture('drive');
+ const libraryGame = path.join(library.root, 'steam-library/steamapps/common/Game');
+ await mkdir(libraryGame, { recursive: true });
+ const libraryRunner = (await prepareProtonRunner(library.wine, library.compat, path.join(library.root, 'steam'), 4, { installPath: libraryGame }))!;
+ const libraryResult = JSON.parse((await execFile(libraryRunner.launchCommand, ['Z:\\game\\Game.exe'], { env: process.env })).stdout.trim().split('\n').pop()!);
+ // Proton maps S: to the parent of the validated `steamapps` directory.
+ expect(libraryResult.game_drive).toBe(await realpath(path.join(library.root, 'steam-library')));
+ }, 60_000);
+});
diff --git a/src/main/proton.test.ts b/src/main/proton.test.ts
index 5898992..1afcf35 100644
--- a/src/main/proton.test.ts
+++ b/src/main/proton.test.ts
@@ -1,11 +1,11 @@
import { execFile as execFileCallback } from 'node:child_process';
import { createHash } from 'node:crypto';
-import { chmod, mkdir, mkdtemp, readFile, readlink, rm, stat, symlink, writeFile } from 'node:fs/promises';
+import { chmod, mkdir, mkdtemp, readFile, readlink, realpath, rm, stat, symlink, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { promisify } from 'node:util';
import { afterEach, describe, expect, it } from 'vitest';
-import { fexEnvironment, managedUnrealCultureGameIni, prefixUserLocale, prepareProtonRunner, protonOptionalComponentNotices, syncPrefixUserLocale, syncUnrealCultureGameIni } from './proton.js';
+import { fexEnvironment, managedUnrealCultureGameIni, prefixUserLocale, prepareProtonRunner, protonOptionalComponentNotices, steamCompatLocation, syncPrefixUserLocale, syncUnrealCultureGameIni } from './proton.js';
import { prepareGameWrapper } from './game-wrapper.js';
import { defaultLaunchTools, parseLaunchOptions } from '../shared/launch-tools.js';
import { preparedGameWine } from './game-launch.js';
@@ -82,8 +82,44 @@ describe('fexEnvironment', () => {
});
});
-describe('prepareProtonRunner', () => {
- it('runs an arm64 runtime from its own loader, prefix and ARM64X component checksums', async () => {
+describe('steamCompatLocation', () => {
+ it('reports only a real install directory and ignores unusable input', async () => {
+ const root = await mkdtemp(path.join(tmpdir(), 'nexus-location-')); created.push(root);
+ const install = path.join(root, 'installs', 'Game');
+ await mkdir(install, { recursive: true });
+ expect(await steamCompatLocation(install)).toEqual({ installPath: await realpath(install) });
+ expect(await steamCompatLocation(path.join(root, 'missing'))).toBeUndefined();
+ expect(await steamCompatLocation('relative/Game')).toBeUndefined();
+ expect(await steamCompatLocation('')).toBeUndefined();
+ const file = path.join(root, 'file'); await writeFile(file, 'data');
+ expect(await steamCompatLocation(file)).toBeUndefined();
+ });
+
+ it('reports a real Steam library only when the install is genuinely inside one', async () => {
+ const root = await mkdtemp(path.join(tmpdir(), 'nexus-location-library-')); created.push(root);
+ const steamapps = path.join(root, 'library', 'steamapps');
+ const game = path.join(steamapps, 'common', 'a', 'b', 'Game');
+ await mkdir(game, { recursive: true });
+ expect(await steamCompatLocation(game)).toEqual({
+ installPath: await realpath(game), libraryPaths: await realpath(steamapps),
+ });
+ // A plain Nexus installation outside a Steam library gets no invented one.
+ const plain = path.join(root, 'nexus', 'Game'); await mkdir(plain, { recursive: true });
+ expect(await steamCompatLocation(plain)).toEqual({ installPath: await realpath(plain) });
+ });
+
+ it('never reports a steamapps path whose real directory has another name', async () => {
+ const root = await mkdtemp(path.join(tmpdir(), 'nexus-location-link-')); created.push(root);
+ const real = path.join(root, 'real'); await mkdir(path.join(real, 'common', 'Game'), { recursive: true });
+ await mkdir(path.join(root, 'library'), { recursive: true });
+ await symlink(real, path.join(root, 'library', 'steamapps'));
+ // The runtime requires the real path basename to be `steamapps`.
+ expect(await steamCompatLocation(path.join(root, 'library', 'steamapps', 'common', 'Game')))
+ .toEqual({ installPath: await realpath(path.join(root, 'library', 'steamapps', 'common', 'Game')) });
+ });
+});
+
+describe('prepareProtonRunner', () => { it('runs an arm64 runtime from its own loader, prefix and ARM64X component checksums', async () => {
const root = await mkdtemp(path.join(tmpdir(), 'nexus-arm64-prefix-')); created.push(root);
const runtime = path.join(root, 'runtime'), compat = path.join(root, 'compat');
const wine = path.join(runtime, 'files/bin-arm64/wine');
@@ -165,6 +201,15 @@ describe('prepareProtonRunner', () => {
expect(launchScript).toContain(`export STEAM_COMPAT_DATA_PATH='${compat}'`);
expect(launchScript).toContain("export UMU_ID='xodus-nexus'");
expect(launchScript).toContain('nexus_game_command="Z:$1"');
+ // Proton's local shader cache root is part of the Play environment only.
+ const shaderPathLine = launchScript.split('\n').find(line => line.startsWith('export STEAM_COMPAT_SHADER_PATH='));
+ expect(shaderPathLine).toBeDefined();
+ const shaderExport = shaderPathLine!.slice('export STEAM_COMPAT_SHADER_PATH='.length);
+ expect(shaderExport.startsWith("'") && shaderExport.endsWith("'")).toBe(true);
+ const shaderPath = shaderExport.slice(1, -1);
+ expect(shaderPath.endsWith('/shadercache/steamapp')).toBe(true);
+ expect((await stat(shaderPath)).isDirectory()).toBe(true);
+ expect(await readFile(runner.command, 'utf8')).not.toContain('STEAM_COMPAT_SHADER_PATH');
// Internal prefix operations and Stop keep the bare Wine command.
const setup=await execFile(runner.command,['setup']);
expect(setup.stdout).not.toContain('fps'); expect(setup.stdout).not.toContain('--launcher-skip');
@@ -197,6 +242,68 @@ describe('prepareProtonRunner', () => {
await execFile(runner.stopPrefix.command,runner.stopPrefix.args);
});
+ it('reports the genuine install location to the Proton session and never fabricates a Steam library', async () => {
+ const root = await mkdtemp(path.join(tmpdir(), 'nexus-proton-location-')); created.push(root);
+ const runtime = path.join(root, 'runtime'), wine = path.join(runtime, 'files/bin/wine');
+ const compat = path.join(root, 'compat'), system32 = path.join(compat, 'pfx/drive_c/windows/system32');
+ await mkdir(path.dirname(wine), { recursive: true });
+ await mkdir(path.join(runtime, 'files/share/default_pfx'), { recursive: true });
+ await mkdir(system32, { recursive: true });
+ for (const name of ['libvkd3d-utils-1.dll', 'dxgi.dll', 'd3d12.dll']) await writeFile(path.join(system32, name), 'ready');
+ // The fixture Proton session reports the location environment it received.
+ await writeFile(path.join(runtime, 'proton'), '#!/bin/sh\nprintf \'install=<%s>\\nlibrary=<%s>\\n\' "${STEAM_COMPAT_INSTALL_PATH-unset}" "${STEAM_COMPAT_LIBRARY_PATHS-unset}"\n', { mode: 0o700 });
+ await writeFile(wine, '#!/bin/sh\nexit 0\n', { mode: 0o700 });
+ await writeFile(path.join(runtime, 'files/bin/wineserver'), '#!/bin/sh\nexit 0\n', { mode: 0o700 });
+ // A parent Steam/launcher process may already export these managed values.
+ const staleEnvironment = { ...process.env, STEAM_COMPAT_INSTALL_PATH: '/stale/install', STEAM_COMPAT_LIBRARY_PATHS: '/stale/library' };
+ const generated = async (installPath?: string) => {
+ const runner = (await prepareProtonRunner(wine, compat, path.join(root, 'steam'), 4, installPath ? { installPath } : {}))!;
+ const { stdout } = await execFile(runner.launchCommand, ['game.exe'], { env: staleEnvironment });
+ const playEnvironment = Object.fromEntries(stdout.trim().split('\n').map((line) => {
+ const equals = line.indexOf('=');
+ return [line.slice(0, equals), line.slice(equals + 1)];
+ }));
+ return {
+ launch: await readFile(runner.launchCommand, 'utf8'),
+ stop: await readFile(runner.command, 'utf8'),
+ playEnvironment,
+ // The launch notice reuses this captured result instead of querying again.
+ location: runner.compatibilityLocation,
+ };
+ };
+ // A Store installation outside a Steam library reports only its real
+ // directory and removes the inherited library value from the Play command.
+ const plainInstall = path.join(root, 'installs', 'Game'); await mkdir(plainInstall, { recursive: true });
+ const plain = await generated(plainInstall);
+ expect(plain.launch).toContain(`export STEAM_COMPAT_INSTALL_PATH='${await realpath(plainInstall)}'`);
+ expect(plain.launch).toContain('unset STEAM_COMPAT_LIBRARY_PATHS');
+ expect(plain.playEnvironment).toEqual({ install: `<${await realpath(plainInstall)}>`, library: '<unset>' });
+ expect(plain.location).toEqual({ installPath: await realpath(plainInstall) });
+ // Internal prefix work and Stop keep their environment unchanged.
+ expect(plain.stop).not.toContain('STEAM_COMPAT_INSTALL_PATH');
+ expect(plain.stop).not.toContain('STEAM_COMPAT_LIBRARY_PATHS');
+ expect(plain.stop).not.toContain('unset STEAM_COMPAT_');
+ // A game genuinely installed inside a Steam library replaces both values.
+ const libraryGame = path.join(root, 'library/steamapps/common/Game'); await mkdir(libraryGame, { recursive: true });
+ const library = await generated(libraryGame);
+ expect(library.launch).toContain(`export STEAM_COMPAT_LIBRARY_PATHS='${await realpath(path.join(root, 'library/steamapps'))}'`);
+ expect(library.playEnvironment).toEqual({
+ install: `<${await realpath(libraryGame)}>`,
+ library: `<${await realpath(path.join(root, 'library/steamapps'))}>`,
+ });
+ expect(library.location).toEqual({
+ installPath: await realpath(libraryGame),
+ libraryPaths: await realpath(path.join(root, 'library/steamapps')),
+ });
+ // Without a verified install directory both inherited values are removed so
+ // the Play environment matches the captured (empty) location context.
+ const missing = await generated(path.join(root, 'absent'));
+ expect(missing.launch).toContain('unset STEAM_COMPAT_INSTALL_PATH');
+ expect(missing.launch).toContain('unset STEAM_COMPAT_LIBRARY_PATHS');
+ expect(missing.playEnvironment).toEqual({ install: '<unset>', library: '<unset>' });
+ expect(missing.location).toBeUndefined();
+ });
+
// The Proton session owns large-address-aware on Play: it enables that flag by
// default, so Play must neither export a Wine default nor let that session
// default replace an explicit launch-option value.
diff --git a/src/main/proton.ts b/src/main/proton.ts
index 15ab406..2c3658e 100644
--- a/src/main/proton.ts
+++ b/src/main/proton.ts
@@ -19,6 +19,8 @@ export interface ProtonRunner {
launchCommand: string;
compatibilityDataPath: string;
protonRoot: string;
+ /** The verified game location reported to the Play command, when known. */
+ compatibilityLocation?: SteamCompatLocation;
stopPrefix: { command: string; args: string[] };
}
@@ -64,6 +66,102 @@ export async function protonOptionalComponentNotices(
return notices;
}
+/**
+ * Proton's own `nonzero()` test for a launch option: only a missing, empty or
+ * literal "0" value disables it (whitespace-only values stay enabled upstream).
+ */
+function upstreamNonzero(value: string | undefined): boolean {
+ return value !== undefined && value.length > 0 && value !== '0';
+}
+
+/**
+ * Reports requested Proton launch options that this runtime cannot act on
+ * through the Nexus Play path. Play runs the runtime's own Proton session
+ * directly without entering the runtime's umu/Steam helper, so options that
+ * helper would serve stay inactive. An optional genuine Steam shortcut handoff
+ * can still provide a Steam game id, so the notices always evaluate the actual
+ * launch environment instead of assuming that identity is missing. They are
+ * reported here instead of being simulated with an invented Steam identity.
+ * Only options the user requested are reported.
+ *
+ * `location` is the verified game-location result the runner captured for this
+ * launch. The game-drive notice is emitted only when that context carries no
+ * real Steam library, so a genuinely mapped S: drive is never reported as
+ * inactive.
+ */
+export async function protonLaunchFeatureNotices(
+ environment: NodeJS.ProcessEnv | Record<string, string | undefined>,
+ protonRoot: string,
+ location?: SteamCompatLocation,
+): Promise<string[]> {
+ const present = async (relative: string): Promise<boolean> => {
+ try { await fs.access(path.join(protonRoot, relative), constants.R_OK); return true; }
+ catch { return false; }
+ };
+ const notices: string[] = [];
+ if (upstreamNonzero(environment.PROTON_DISCORD_BRIDGE)) {
+ if (await present('files/lib/wine/discord-rpc-bridge/bridge.exe')) {
+ notices.push('PROTON_DISCORD_BRIDGE is set. The Discord RPC bridge is installed in this runtime, but its service is started only by the runtime umu or Steam helper. This launch starts the runtime Proton session directly and does not start the bridge, so Rich Presence stays inactive.');
+ } else {
+ notices.push('PROTON_DISCORD_BRIDGE is set, but this runtime does not include the Discord RPC bridge, so the option has no effect.');
+ }
+ }
+ if (upstreamNonzero(environment.PROTON_LOCAL_SHADER_CACHE) && !await present('protonfixes/utilities.py')) {
+ notices.push('PROTON_LOCAL_SHADER_CACHE is set, but this runtime does not implement it, so the option has no effect.');
+ }
+ // Proton's own log file exists only when the effective environment carries a
+ // Steam game id; the pinned setup_logging checks key presence, not the value.
+ // A genuine Steam shortcut handoff or an ambient value both satisfy it.
+ if (upstreamNonzero(environment.PROTON_LOG) && environment.SteamGameId === undefined) {
+ notices.push('PROTON_LOG is set, but Proton creates its log file only when the launch provides a Steam game id, and this launch has none. The configured Wine and DXVK logging variables still apply.');
+ }
+ if (upstreamNonzero(environment.PROTON_SET_GAME_DRIVE) && !location?.libraryPaths) {
+ notices.push('PROTON_SET_GAME_DRIVE is set, but this game is not installed inside a verified Steam library (a real steamapps directory), so Proton has no library for the S: game drive. Nexus does not fabricate one. The other mount drives follow the runtime.');
+ }
+ return notices;
+}
+
+export interface SteamCompatLocation {
+ /** The real install directory Proton receives as the game location. */
+ installPath: string;
+ /** A real `steamapps` directory containing the install, when one exists. */
+ libraryPaths?: string;
+}
+
+/**
+ * Location context for Proton's own drive mapping. `PROTON_SET_GAME_DRIVE`
+ * maps S: to the parent of a `steamapps` directory that contains the game, and
+ * the runtime itself validates the library parent (writable, same device).
+ * Nexus reports the genuine install directory, and the real library only when
+ * the game is actually installed inside one. A Store installation outside a
+ * Steam library reports just the install directory, so nothing is fabricated
+ * for a Steam-only drive.
+ */
+export async function steamCompatLocation(installPath: string): Promise<SteamCompatLocation | undefined> {
+ if (!installPath || !path.isAbsolute(installPath)) return undefined;
+ let install: string;
+ try {
+ install = await fs.realpath(installPath);
+ if (!(await fs.stat(install)).isDirectory()) return undefined;
+ } catch { return undefined; }
+ const located: SteamCompatLocation = { installPath: install };
+ let directory = path.dirname(install);
+ for (;;) {
+ if (path.basename(directory) === 'steamapps') {
+ try {
+ // The runtime looks up the real path and requires the basename
+ // `steamapps`. Report the library only when it would satisfy that.
+ const library = await fs.realpath(directory);
+ if (path.basename(library) === 'steamapps' && (await fs.stat(library)).isDirectory()) located.libraryPaths = library;
+ } catch { /* A library the runtime would reject stays unreported. */ }
+ return located;
+ }
+ const parent = path.dirname(directory);
+ if (parent === directory) return located;
+ directory = parent;
+ }
+}
+
const REQUIRED_PREFIX_FILES = [
'drive_c/windows/system32/libvkd3d-utils-1.dll',
'drive_c/windows/system32/dxgi.dll',
@@ -437,6 +535,7 @@ export async function prepareProtonRunner(
compatibilityDataPath: string,
steamRoot: string,
shaderCacheLimitGiB = DEFAULT_SHADER_CACHE_GIB,
+ options: { installPath?: string } = {},
): Promise<ProtonRunner | undefined> {
const cacheLimits = shaderCacheLimits(shaderCacheLimitGiB);
// An arm64 runtime keeps its own loader, prefix and ARM64X modules; Proton's
@@ -633,9 +732,29 @@ export async function prepareProtonRunner(
// launch options of that runtime, for example PROTON_USE_OPTISCALER, before it
// starts the game. Launch options still arrive in this process environment.
const temporaryLaunch = `${launchScript}.tmp-${process.pid}`;
+ const compatLocation = options.installPath ? await steamCompatLocation(options.installPath) : undefined;
await fs.writeFile(temporaryLaunch, sharedScript([`${shellQuote(proton)} run "$@"`], [
`export STEAM_COMPAT_DATA_PATH=${shellQuote(compatibilityDataPath)}`,
`export STEAM_COMPAT_CLIENT_INSTALL_PATH=${shellQuote(steamRoot)}`,
+ // Proton's own shader cache switch (PROTON_LOCAL_SHADER_CACHE) reads
+ // STEAM_COMPAT_SHADER_PATH. Steam points it at the per-game shader cache, so
+ // Nexus maps it to the managed cache of this prefix instead of inventing a
+ // Steam library. The runtime keeps the driver caches above: it only applies
+ // its own paths through setdefault.
+ `export STEAM_COMPAT_SHADER_PATH=${shellQuote(shaderCaches.steamapp)}`,
+ // Proton's game drive reads the game location from its environment. Report
+ // the real install directory, and the genuine Steam library only when the
+ // game is installed inside a `steamapps` directory; a Store installation
+ // outside one gets no invented library. These two managed variables must
+ // also match the captured context in the other direction: a verified value
+ // replaces an inherited Steam/launcher value, and without one Play removes
+ // it instead of letting a stale ambient value contradict the launch notice.
+ ...(compatLocation
+ ? [`export STEAM_COMPAT_INSTALL_PATH=${shellQuote(compatLocation.installPath)}`]
+ : ['unset STEAM_COMPAT_INSTALL_PATH']),
+ ...(compatLocation?.libraryPaths
+ ? [`export STEAM_COMPAT_LIBRARY_PATHS=${shellQuote(compatLocation.libraryPaths)}`]
+ : ['unset STEAM_COMPAT_LIBRARY_PATHS']),
// Proton's session selects its launch route from UMU_ID, UMU_USE_STEAM and
// whether the executable argument is a Unix path: with UMU_ID unset it runs
// steam.exe, and a leading "/" selects umu.exe. Nexus starts the runtime's own
@@ -652,5 +771,5 @@ export async function prepareProtonRunner(
], true), { mode: 0o700 });
await fs.rename(temporaryLaunch, launchScript);
await fs.chmod(launchScript, 0o700);
- return { command: runner, launchCommand: launchScript, compatibilityDataPath, protonRoot, stopPrefix: { command: runner, args: ['--nexus-stop-prefix'] } };
+ return { command: runner, launchCommand: launchScript, compatibilityDataPath, protonRoot, compatibilityLocation: compatLocation, stopPrefix: { command: runner, args: ['--nexus-stop-prefix'] } };
}
diff --git a/src/main/shader-cache.test.ts b/src/main/shader-cache.test.ts
index d3ee87a..db06b33 100644
--- a/src/main/shader-cache.test.ts
+++ b/src/main/shader-cache.test.ts
@@ -75,7 +75,7 @@ describe('persistent shader cache', () => {
__GL_SHADER_DISK_CACHE_SKIP_CLEANUP: null, MESA_SHADER_CACHE_MAX_SIZE: null });
});
- it.each(['shadercache', 'shadercache/vkd3d-proton', 'shadercache/nvidia', 'shadercache/mesa'])('refuses a managed cache symlink: %s', async relative => {
+ it.each(['shadercache', 'shadercache/vkd3d-proton', 'shadercache/nvidia', 'shadercache/mesa', 'shadercache/steamapp'])('refuses a managed cache symlink: %s', async relative => {
const f = await fixture(), outside = path.join(f.root, 'outside');
await fs.mkdir(outside, { mode: 0o755 }); await fs.writeFile(path.join(outside, 'keep'), 'unchanged');
const link = path.join(f.compat, relative); await fs.mkdir(path.dirname(link), { recursive: true }); await fs.symlink(outside, link);
@@ -93,10 +93,10 @@ describe('persistent shader cache', () => {
it('repairs only owned directory permissions, preserving cached bytes and file modes', async () => {
const f = await fixture();
- for (const name of ['', 'vkd3d-proton', 'nvidia', 'mesa']) { const dir = path.join(f.cache, name); await fs.mkdir(dir, { recursive: true }); await fs.chmod(dir, 0o777); }
+ for (const name of ['', 'vkd3d-proton', 'nvidia', 'mesa', 'steamapp']) { const dir = path.join(f.cache, name); await fs.mkdir(dir, { recursive: true }); await fs.chmod(dir, 0o777); }
const cached = path.join(f.cache, 'mesa/cache'); await fs.writeFile(cached, 'warm', { mode: 0o640 });
await prepareProtonRunner(f.wine, f.compat, f.steam);
- for (const name of ['', 'vkd3d-proton', 'nvidia', 'mesa']) expect((await fs.stat(path.join(f.cache, name))).mode & 0o777).toBe(0o700);
+ for (const name of ['', 'vkd3d-proton', 'nvidia', 'mesa', 'steamapp']) expect((await fs.stat(path.join(f.cache, name))).mode & 0o777).toBe(0o700);
expect(await fs.readFile(cached, 'utf8')).toBe('warm'); expect((await fs.stat(cached)).mode & 0o777).toBe(0o640);
});
@@ -183,3 +183,177 @@ describe('persistent shader cache', () => {
await expect(fs.access(path.join(f.cache, 'vkd3d-proton/synthetic-cache'))).rejects.toThrow(); await tools.cleanup();
});
});
+
+// PROTON_LOCAL_SHADER_CACHE is Proton's own per-game shader cache switch. The
+// runtime only reaches it through STEAM_COMPAT_SHADER_PATH, so this fixture
+// implements the documented upstream rule: on the `run` verb the session creates
+// the per-game cache directories and exports their variables with setdefault.
+// Any driver cache Nexus already exported therefore keeps its value.
+describe('Proton local shader cache through the Play command', () => {
+ const localKeys = ['STEAM_COMPAT_SHADER_PATH', 'DXVK_STATE_CACHE_PATH', 'AMD_VK_PIPELINE_CACHE_PATH',
+ 'VKD3D_SHADER_CACHE_PATH', 'MESA_SHADER_CACHE_DIR', 'MESA_SHADER_CACHE_MAX_SIZE',
+ '__GL_SHADER_DISK_CACHE_PATH', '__GL_SHADER_DISK_CACHE_SIZE'];
+ async function localFixture() {
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), 'nexus-proton-local-cache-')); roots.push(root);
+ const files = path.join(root, "runtime's files", 'files');
+ const wine = path.join(files, 'bin/wine'), proton = path.join(files, '..', 'proton');
+ const compat = path.join(root, 'compat'), system = path.join(compat, 'pfx/drive_c/windows/system32');
+ await fs.mkdir(path.dirname(wine), { recursive: true });
+ await fs.mkdir(path.join(files, 'share/default_pfx'), { recursive: true });
+ await fs.mkdir(system, { recursive: true });
+ for (const name of ['libvkd3d-utils-1.dll', 'dxgi.dll', 'd3d12.dll']) await fs.writeFile(path.join(system, name), 'fixture');
+ await fs.writeFile(proton, `#!${process.execPath}
+const {spawnSync}=require('child_process');const fs=require('fs');
+const args=process.argv.slice(2);
+const nonzero=value=>value!==undefined&&value.length>0&&value!=='0';
+if(args[0]==='run'){
+ args.shift();
+ if(nonzero(process.env.PROTON_LOCAL_SHADER_CACHE)&&process.env.STEAM_COMPAT_SHADER_PATH){
+ const base=process.env.STEAM_COMPAT_SHADER_PATH;
+ const vars={__GL_SHADER_DISK_CACHE_APP_NAME:'steamapp_shader_cache',__GL_SHADER_DISK_CACHE_PATH:base+'/nvidiav1',
+ __GL_SHADER_DISK_CACHE_SIZE:'10737418240',MESA_SHADER_CACHE_DIR:base,MESA_SHADER_CACHE_MAX_SIZE:'10G',
+ AMD_VK_PIPELINE_CACHE_PATH:base+'/AMDv1',DXVK_STATE_CACHE_PATH:base+'/DXVK_state_cache',
+ VKD3D_SHADER_CACHE_PATH:base+'/VKD3D_shader_cache'};
+ for(const name of ['__GL_SHADER_DISK_CACHE_PATH','MESA_SHADER_CACHE_DIR','AMD_VK_PIPELINE_CACHE_PATH','DXVK_STATE_CACHE_PATH','VKD3D_SHADER_CACHE_PATH'])fs.mkdirSync(vars[name],{recursive:true});
+ for(const [name,value] of Object.entries(vars))if(!(name in process.env))process.env[name]=value;
+ }
+}
+const result=spawnSync(${JSON.stringify(wine)},args,{stdio:'inherit'});process.exit(result.status??1);
+`, { mode: 0o700 });
+ await fs.writeFile(wine, `#!${process.execPath}
+console.log(JSON.stringify(Object.fromEntries(${JSON.stringify(localKeys)}.map(k=>[k,process.env[k]??null]))));
+`, { mode: 0o700 });
+ return { root, wine, compat, steam: path.join(root, 'steam'), cache: path.join(compat, 'shadercache') };
+ }
+ function localEnvironment(extra: NodeJS.ProcessEnv = {}): NodeJS.ProcessEnv {
+ const env = environment();
+ delete env.STEAM_COMPAT_SHADER_PATH; delete env.PROTON_LOCAL_SHADER_CACHE;
+ return { ...env, ...extra };
+ }
+
+ it('maps PROTON_LOCAL_SHADER_CACHE to the managed per-prefix cache and keeps the driver caches', async () => {
+ const f = await localFixture(), runner = (await prepareProtonRunner(f.wine, f.compat, f.steam))!;
+ const launchScript = await fs.readFile(runner.launchCommand, 'utf8');
+ expect(launchScript).toContain(`export STEAM_COMPAT_SHADER_PATH='${path.join(f.cache, 'steamapp')}'`);
+ // Internal prefix work and Stop never enter the Proton session.
+ expect(await fs.readFile(runner.command, 'utf8')).not.toContain('STEAM_COMPAT_SHADER_PATH');
+ // The variable is inert until the game requests the local cache.
+ const off = JSON.parse((await execFile(runner.launchCommand, [], { env: localEnvironment() })).stdout);
+ expect(off.STEAM_COMPAT_SHADER_PATH).toBe(path.join(f.cache, 'steamapp'));
+ expect(off.DXVK_STATE_CACHE_PATH).toBeNull();
+ expect(off.AMD_VK_PIPELINE_CACHE_PATH).toBeNull();
+ await expect(fs.access(path.join(f.cache, 'steamapp/DXVK_state_cache'))).rejects.toThrow();
+ const setup = JSON.parse((await execFile(runner.command, [], { env: localEnvironment() })).stdout);
+ expect(setup.STEAM_COMPAT_SHADER_PATH).toBeNull();
+ await expect(fs.access(path.join(f.cache, 'steamapp/AMDv1'))).rejects.toThrow();
+ // The real user path: the request arrives through the game's launch options.
+ const tools = await prepareGameWrapper(runner.launchCommand, { ...defaultLaunchTools,
+ launchOptions: 'PROTON_LOCAL_SHADER_CACHE=1 %command%' }, path.join(f.root, 'wrappers'), localEnvironment());
+ const on = JSON.parse((await execFile(tools.command, ['game.exe'], { env: localEnvironment() })).stdout);
+ expect(on.DXVK_STATE_CACHE_PATH).toBe(path.join(f.cache, 'steamapp/DXVK_state_cache'));
+ expect(on.AMD_VK_PIPELINE_CACHE_PATH).toBe(path.join(f.cache, 'steamapp/AMDv1'));
+ for (const name of ['nvidiav1', 'AMDv1', 'DXVK_state_cache', 'VKD3D_shader_cache']) expect((await fs.stat(path.join(f.cache, 'steamapp', name))).isDirectory()).toBe(true);
+ // Proton only setdefaults these, so the managed caches of the prefix win.
+ expect(on.__GL_SHADER_DISK_CACHE_PATH).toBe(path.join(f.cache, 'nvidia'));
+ expect(on.__GL_SHADER_DISK_CACHE_SIZE).toBe('4294967296');
+ expect(on.VKD3D_SHADER_CACHE_PATH).toBe(path.join(f.cache, 'vkd3d-proton'));
+ expect(on.MESA_SHADER_CACHE_DIR).toBe(path.join(f.cache, 'mesa'));
+ expect(on.MESA_SHADER_CACHE_MAX_SIZE).toBe('4G');
+ await tools.cleanup();
+ });
+
+ it('keeps an explicit disabled request from enabling the local cache', async () => {
+ const f = await localFixture(), runner = (await prepareProtonRunner(f.wine, f.compat, f.steam))!;
+ for (const value of ['0', '']) {
+ const result = JSON.parse((await execFile(runner.launchCommand, [], { env: localEnvironment({ PROTON_LOCAL_SHADER_CACHE: value }) })).stdout);
+ expect(result.DXVK_STATE_CACHE_PATH).toBeNull();
+ expect(result.AMD_VK_PIPELINE_CACHE_PATH).toBeNull();
+ }
+ await expect(fs.access(path.join(f.cache, 'steamapp/DXVK_state_cache'))).rejects.toThrow();
+ });
+});
+
+// Deep optional check: the pinned protonfixes source itself consumes the
+// environment the Play command exports. It needs no Wine or Proton binary and is
+// skipped unless the module checkout is provided. Environment contract:
+// XODUS_PROTONFIXES_SOURCE=/path/to/the/protonfixes/module
+// (the directory that directly contains utilities.py)
+// Only the `setup_local_shader_cache` function is extracted and executed, so the
+// package is never imported (no __init__, protonfixes helpers, upscalers or
+// network), and nothing is written into the checkout.
+const protonfixesSource = process.env.XODUS_PROTONFIXES_SOURCE;
+describe.skipIf(!protonfixesSource)('pinned protonfixes local shader cache', () => {
+ const quote = (value: string) => `'${value.replaceAll("'", `'"'"'`)}'`;
+ const keys = ['STEAM_COMPAT_SHADER_PATH', 'DXVK_STATE_CACHE_PATH', 'AMD_VK_PIPELINE_CACHE_PATH',
+ 'VKD3D_SHADER_CACHE_PATH', 'MESA_SHADER_CACHE_DIR', 'MESA_SHADER_CACHE_MAX_SIZE',
+ '__GL_SHADER_DISK_CACHE_PATH', '__GL_SHADER_DISK_CACHE_SIZE'];
+ async function pinnedFixture() {
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), 'nexus-protonfixes-source-')); roots.push(root);
+ const files = path.join(root, 'runtime', 'files');
+ const wine = path.join(files, 'bin/wine'), proton = path.join(root, 'runtime', 'proton');
+ const compat = path.join(root, 'compat'), system = path.join(compat, 'pfx/drive_c/windows/system32');
+ const probe = path.join(root, 'probe.py'), envOut = path.join(root, 'environment.json');
+ await fs.mkdir(path.dirname(wine), { recursive: true });
+ await fs.mkdir(path.join(files, 'share/default_pfx'), { recursive: true });
+ await fs.mkdir(system, { recursive: true });
+ for (const name of ['libvkd3d-utils-1.dll', 'dxgi.dll', 'd3d12.dll']) await fs.writeFile(path.join(system, name), 'fixture');
+ // Only the pinned function is compiled and run. The package (and its
+ // __init__, helpers and upscalers) is never imported, so no import side
+ // effect or bytecode write can occur in the checkout.
+ await fs.writeFile(probe, `import ast, json, os, subprocess, sys
+source = os.path.join(${JSON.stringify(protonfixesSource)}, 'utilities.py')
+with open(source, encoding='utf-8') as handle:
+ tree = ast.parse(handle.read(), filename=source)
+found = [node for node in tree.body
+ if isinstance(node, ast.FunctionDef) and node.name == 'setup_local_shader_cache']
+if len(found) != 1:
+ raise SystemExit(f'expected exactly one setup_local_shader_cache, found {len(found)}')
+namespace = {'os': os}
+exec(compile(ast.Module(body=[found[0]], type_ignores=[]), source, 'exec'), namespace)
+# Mirrors the pinned session for the run verb: check_environment() records the
+# compat option, then the utility receives the process environment.
+config = set()
+value = os.environ.get("PROTON_LOCAL_SHADER_CACHE", "")
+if len(value) > 0 and value != "0":
+ config.add("localshadercache")
+namespace['setup_local_shader_cache'](config, os.environ)
+sys.exit(subprocess.call([sys.argv[1]] + sys.argv[2:], env=os.environ))
+`);
+ await fs.writeFile(proton, `#!/bin/sh\n[ "$1" = run ] || exec ${quote(wine)} "$@"\nshift\nexec python3 ${quote(probe)} ${quote(wine)} "$@"\n`, { mode: 0o700 });
+ await fs.writeFile(wine, `#!${process.execPath}
+const fs=require('fs');
+fs.writeFileSync(process.env.ENV_OUT,JSON.stringify(Object.fromEntries(${JSON.stringify(keys)}.map(k=>[k,process.env[k]??null]))));
+`, { mode: 0o700 });
+ return { root, wine, compat, steam: path.join(root, 'steam'), cache: path.join(compat, 'shadercache'), envOut };
+ }
+ function pinnedEnvironment(extra: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
+ const env = { ...process.env };
+ for (const key of [...keys, 'PROTON_LOCAL_SHADER_CACHE', 'DXVK_HUD', 'MESA_SHADER_CACHE_DISABLE']) delete env[key];
+ return { ...env, ...extra };
+ }
+
+ it('uses the exported shader path for its per-game caches and keeps the managed driver caches', async () => {
+ const f = await pinnedFixture(), runner = (await prepareProtonRunner(f.wine, f.compat, f.steam))!;
+ await execFile(runner.launchCommand, ['game.exe'],
+ { env: pinnedEnvironment({ PROTON_LOCAL_SHADER_CACHE: '1', ENV_OUT: f.envOut, PYTHONDONTWRITEBYTECODE: '1' }) });
+ const on = JSON.parse(await fs.readFile(f.envOut, 'utf8'));
+ expect(on.DXVK_STATE_CACHE_PATH).toBe(path.join(f.cache, 'steamapp/DXVK_state_cache'));
+ expect(on.AMD_VK_PIPELINE_CACHE_PATH).toBe(path.join(f.cache, 'steamapp/AMDv1'));
+ // The upstream helper only setdefaults these, so the managed values win.
+ expect(on.__GL_SHADER_DISK_CACHE_PATH).toBe(path.join(f.cache, 'nvidia'));
+ expect(on.__GL_SHADER_DISK_CACHE_SIZE).toBe('4294967296');
+ expect(on.VKD3D_SHADER_CACHE_PATH).toBe(path.join(f.cache, 'vkd3d-proton'));
+ expect(on.MESA_SHADER_CACHE_DIR).toBe(path.join(f.cache, 'mesa'));
+ expect(on.MESA_SHADER_CACHE_MAX_SIZE).toBe('4G');
+ for (const name of ['nvidiav1', 'AMDv1', 'DXVK_state_cache', 'VKD3D_shader_cache']) expect((await fs.stat(path.join(f.cache, 'steamapp', name))).isDirectory()).toBe(true);
+ // An unrequested local cache keeps the prefix free of Proton-owned state.
+ await fs.rm(path.join(f.cache, 'steamapp'), { recursive: true, force: true });
+ await fs.mkdir(path.join(f.cache, 'steamapp'), { mode: 0o700 });
+ await execFile(runner.launchCommand, ['game.exe'], { env: pinnedEnvironment({ ENV_OUT: f.envOut, PYTHONDONTWRITEBYTECODE: '1' }) });
+ const off = JSON.parse(await fs.readFile(f.envOut, 'utf8'));
+ expect(off.STEAM_COMPAT_SHADER_PATH).toBe(path.join(f.cache, 'steamapp'));
+ expect(off.DXVK_STATE_CACHE_PATH).toBeNull();
+ expect(off.AMD_VK_PIPELINE_CACHE_PATH).toBeNull();
+ expect(await fs.readdir(path.join(f.cache, 'steamapp'))).toEqual([]);
+ });
+});
diff --git a/src/main/shader-cache.ts b/src/main/shader-cache.ts
index ba5116f..25030de 100644
--- a/src/main/shader-cache.ts
+++ b/src/main/shader-cache.ts
@@ -22,8 +22,16 @@ async function privateDirectory(directory: string, create = false): Promise<File
} catch (error) { await handle.close(); throw error; }
}
+export interface ShaderCachePaths {
+ vkd3d: string;
+ nvidia: string;
+ mesa: string;
+ /** Per-game root for Proton's own `PROTON_LOCAL_SHADER_CACHE` layout. */
+ steamapp: string;
+}
+
/** Only owned cache directories are managed. Never clear cache files or follow links. */
-export async function prepareShaderCache(compatibilityDataPath: string): Promise<{ vkd3d: string; nvidia: string; mesa: string }> {
+export async function prepareShaderCache(compatibilityDataPath: string): Promise<ShaderCachePaths> {
if (!path.isAbsolute(compatibilityDataPath)) throw Error('The shader cache prefix path must be absolute.');
const root = await privateDirectory(compatibilityDataPath);
try {
@@ -31,7 +39,7 @@ export async function prepareShaderCache(compatibilityDataPath: string): Promise
// Anchor creation to checked directory handles, not a replaceable parent path.
const cache = await privateDirectory(`/proc/self/fd/${root.fd}/shadercache`, true);
try {
- for (const name of ['vkd3d-proton', 'nvidia', 'mesa']) {
+ for (const name of ['vkd3d-proton', 'nvidia', 'mesa', 'steamapp']) {
const child = await privateDirectory(`/proc/self/fd/${cache.fd}/${name}`, true);
await child.close();
}
@@ -42,7 +50,12 @@ export async function prepareShaderCache(compatibilityDataPath: string): Promise
const directory = path.join(await fs.realpath(compatibilityDataPath), 'shadercache');
const top = await fs.lstat(directory), checked = await cache.stat();
if (top.isSymbolicLink() || top.dev !== checked.dev || top.ino !== checked.ino) throw Error('The shader cache directory changed during preparation.');
- return { vkd3d: path.join(directory, 'vkd3d-proton'), nvidia: path.join(directory, 'nvidia'), mesa: path.join(directory, 'mesa') };
+ return {
+ vkd3d: path.join(directory, 'vkd3d-proton'),
+ nvidia: path.join(directory, 'nvidia'),
+ mesa: path.join(directory, 'mesa'),
+ steamapp: path.join(directory, 'steamapp'),
+ };
} finally { await cache.close(); }
} finally { await root.close(); }
}
diff --git a/src/shared/launch-tools.test.ts b/src/shared/launch-tools.test.ts
index cd5a143..fb9799b 100644
--- a/src/shared/launch-tools.test.ts
+++ b/src/shared/launch-tools.test.ts
@@ -13,10 +13,41 @@ it.each(['mangohud %command% %command%', 'a%command%', 'bad "quote', 'bad\\', 'x
expect(() => parseLaunchOptions(value)).toThrow();
});
-it.each(['WINEPREFIX=/other', 'XODUS_SOCKET=/other', 'WINE_DLL_FILE_MAP=bad', 'STEAM_COMPAT_DATA_PATH=/other'])('protects managed identity/prefix settings: %s', value => {
+it.each(['WINEPREFIX=/other', 'XODUS_SOCKET=/other', 'WINE_DLL_FILE_MAP=bad', 'STEAM_COMPAT_DATA_PATH=/other',
+ 'STEAM_COMPAT_CONFIGX=1', 'STEAM_COMPAT_CONFIG_EXTRA=1', 'STEAM_COMPAT_INSTALL_PATH=/other',
+ 'STEAM_COMPAT_LIBRARY_PATHS=/other', 'STEAM_COMPAT_SHADER_PATH=/other', 'STEAM_COMPAT_APP_ID=1',
+ 'XODUS_ANYTHING=1'])('protects managed identity/prefix settings: %s', value => {
expect(() => parseLaunchOptions(value)).toThrow('managed by Nexus');
});
+it('keeps case variants as inert data because the managed names are exact', () => {
+ // Linux environment names are case sensitive: Wine and Proton read the exact
+ // upper-case names, so a different spelling cannot shadow them.
+ expect(parseLaunchOptions('WinEPREFIX=/other %command%').environment).toEqual({ WinEPREFIX: '/other' });
+ expect(parseLaunchOptions('steam_compat_data_path=/other %command%').environment).toEqual({ steam_compat_data_path: '/other' });
+});
+
+it('accepts the documented Proton compat-config channel as launch data', () => {
+ // Proton reads this variable from its environment and only adds compat option
+ // names to its own config set or appends data to its argv.
+ expect(parseLaunchOptions('STEAM_COMPAT_CONFIG=wined3d %command%')).toEqual({
+ environment: { STEAM_COMPAT_CONFIG: 'wined3d' }, prefix: [], gameArgs: [],
+ });
+ expect(parseLaunchOptions('STEAM_COMPAT_CONFIG="cmdlineappend:--flag value,wined3d,localshadercache" %command%')).toEqual({
+ environment: { STEAM_COMPAT_CONFIG: 'cmdlineappend:--flag value,wined3d,localshadercache' }, prefix: [], gameArgs: [],
+ });
+ // An explicit empty, literal zero or whitespace-only value is data too: the
+ // launcher never rewrites it, Proton applies its own nonzero rule.
+ expect(parseLaunchOptions('STEAM_COMPAT_CONFIG= %command%').environment.STEAM_COMPAT_CONFIG).toBe('');
+ expect(parseLaunchOptions('STEAM_COMPAT_CONFIG=0 %command%').environment.STEAM_COMPAT_CONFIG).toBe('0');
+ expect(parseLaunchOptions('STEAM_COMPAT_CONFIG=" " %command%').environment.STEAM_COMPAT_CONFIG).toBe(' ');
+ // Shell-looking characters stay literal inside a quoted assignment.
+ expect(parseLaunchOptions('STEAM_COMPAT_CONFIG="cmdlineappend:$(touch /tmp/x) `id`;a" %command%').environment.STEAM_COMPAT_CONFIG)
+ .toBe('cmdlineappend:$(touch /tmp/x) `id`;a');
+ // A space before the equals sign is not an assignment and never becomes one.
+ expect(parseLaunchOptions('STEAM_COMPAT_CONFIG =wined3d %command%').prefix).toEqual(['STEAM_COMPAT_CONFIG', '=wined3d']);
+});
+
it('validates persisted launch tool settings at the IPC boundary', () => {
expect(normalizeLaunchTools(undefined)).toEqual(defaultLaunchTools);
expect(() => normalizeLaunchTools({ ...defaultLaunchTools, mangoHud:'yes' })).toThrow();
diff --git a/src/shared/launch-tools.ts b/src/shared/launch-tools.ts
index 7794a3e..09e1690 100644
--- a/src/shared/launch-tools.ts
+++ b/src/shared/launch-tools.ts
@@ -35,7 +35,11 @@ export function parseLaunchOptions(input: string): { environment: Record<string,
while (/^[A-Za-z_][A-Za-z0-9_]*=/.test(prefix[0] ?? '')) {
const assignment = prefix.shift()!, equals = assignment.indexOf('=');
const name = assignment.slice(0, equals);
- if (/^(?:WINEPREFIX|WINEARCH|WINE_DLL_FILE_MAP|XODUS_.*|STEAM_COMPAT_.*)$/.test(name)) throw Error(`${name} is managed by Nexus and cannot be overridden in launch options.`);
+ // Proton reads its documented compat-config channel from the launch
+ // environment. The value only adds compat option names and appends argv
+ // data inside the Proton script, so a game may set it. Every other
+ // STEAM_COMPAT_* variable and the prefix/identity variables stay managed.
+ if (name !== 'STEAM_COMPAT_CONFIG' && /^(?:WINEPREFIX|WINEARCH|WINE_DLL_FILE_MAP|XODUS_.*|STEAM_COMPAT_.*)$/.test(name)) throw Error(`${name} is managed by Nexus and cannot be overridden in launch options.`);
environment[name] = assignment.slice(equals + 1);
}
return { environment, prefix, gameArgs: marker < 0 ? [] : words.slice(marker + 1) };