Files
nixos/hosts/yarn/default.nix
Simon Gardling e010b4e3c1 game-mods: drop in-house launchOptions writer, hardcode FH5 ini
Replaces three handfuls of custom code with upstream / static data:

- Per-app Steam launch options now declared via different-name/steam-
  config-nix's `programs.steam.config.apps.<n>` instead of a custom
  ~70-line `apply_launch_options` Python function. The dropped writer
  was racy: it edited localconfig.vdf without checking for a running
  Steam, so any timer firing while Steam was open would lose its
  changes on the next Steam shutdown. steam-config-nix's `closeSteam`
  flag closes that race.

  Also moves the GE-Proton compat-tool pin to declarative config —
  one fewer manual click in Steam UI to remember.

- `mods.<>.launchOptions` option, the `launchOptionsData` aggregation,
  and `LAUNCH_OPTIONS_DATA` are removed from desktop-game-mods.nix.
  The module now does file-drops only; Steam config lives in its own
  `programs.steam.config` namespace, where it belongs.

  fh5-vkd3d-no-hvv (which existed only to set VKD3D_CONFIG) collapses
  into the FH5 launchOptions block in hosts/yarn/default.nix.

- `unitConfig.X-ConfigHash` on game-mods.service is replaced with
  `restartTriggers`. NixOS already emits `X-Restart-Triggers=<hash>`
  on the unit; the workaround was redundant. The Type=oneshot,
  RemainAfterExit=no semantics make `systemctl restart` re-run
  ExecStart cleanly on hash change.

- The awk pipeline that patched OptiScaler's stock OptiScaler.ini at
  build time is replaced with a hand-written hosts/yarn/optiscaler-
  fh5-rdna3.ini containing only the keys we override (5 of them).
  OptiScaler's Config::readString defaults missing keys to "auto"
  (Config.cpp:1568), so a minimal file is sufficient. Side benefits:
  one upstream-source dependency removed, a key-rename in upstream
  becomes a behavior change rather than a silent awk-no-match.

  Override values + sources:
    Fsr4Update=true              FH5 wiki, FSR4 Linux Setup
    DlssReactiveMaskBias=0.65    FH5 wiki, "Known Issues"
    FsrNonLinearColorSpace=true  FSR4 wiki, "Image Quality"
    EnableFsr2Inputs=false       FH5 wiki, "Known Issues"
    Dxgi=false                   FH5 wiki

- forza-trigger's three custom Python derivations (pydualsense,
  hidapi-usb, fdp) factored out of default.nix into a sibling
  python-packages.nix. Same logic, single-purpose file. Bumping a
  version is now a one-place hash roll.

- pkgs.dualsensectl removed from the daemon's environment.system-
  Packages. Single-shot writes from the CLI get clobbered by the BG
  sendReport thread within ~4ms anyway, so the tool is only useful
  with the daemon stopped — not worth the unconditional install.
  Bring it in ad-hoc with `nix-shell -p dualsensectl`.
2026-05-03 00:35:49 -04:00

187 lines
6.0 KiB
Nix

{
pkgs,
lib,
username,
inputs,
site_config,
...
}:
{
imports = [
../../modules/desktop-common.nix
../../modules/desktop-jovian.nix
../../modules/no-rgb.nix
./disk.nix
./impermanence.nix
./lact.nix
./vr.nix
./forza-trigger
../../modules/desktop-game-mods.nix
inputs.impermanence.nixosModules.impermanence
];
fileSystems."/media/games" = {
device = "/dev/disk/by-uuid/1878136e-765d-4784-b204-3536ab4fdac8";
fsType = "f2fs";
options = [ "nofail" ];
};
systemd.targets = {
sleep.enable = false;
suspend.enable = false;
hibernate.enable = false;
hybrid-sleep.enable = false;
};
networking.hostId = "abf570f9";
# Static IP for consistent SSH access
networking.networkmanager.ensureProfiles.profiles.enp7s0-static = {
connection = {
id = "enp7s0-static";
type = "ethernet";
interface-name = "enp7s0";
autoconnect = true;
};
ipv4 = {
method = "manual";
address1 = "${site_config.hosts.yarn.ip}/24,${site_config.lan.gateway}";
dns = lib.concatMapStrings (n: "${n};") site_config.dns_servers;
};
ipv6.method = "disabled";
};
services.openssh = {
enable = true;
ports = [ 22 ];
settings = {
PasswordAuthentication = false;
PermitRootLogin = "yes";
};
};
users.users.${username}.openssh.authorizedKeys.keys = [
site_config.ssh_keys.laptop
];
users.users.root.openssh.authorizedKeys.keys = [
site_config.ssh_keys.laptop
site_config.ssh_keys.ci_deploy
];
programs.steam = {
remotePlay.openFirewall = true;
localNetworkGameTransfers.openFirewall = true;
};
environment.systemPackages = [ pkgs.jovian-stubs ];
# yarn is not a Steam Deck
jovian.devices.steamdeck.enable = false;
# PS5 DualSense adaptive triggers in Forza Horizon 4 / 5.
services.forzaTrigger.enable = true;
# Declarative game-file mods on top of Steam (file drops only; Steam launch
# options live in `programs.steam.config.apps` below).
#
# fh5-no-intro: stub the 40 MB T10/Microsoft Studios cold-start splash.
# Two copies live in the install (SD + hires); engine picks one based on
# the installed asset profile, so stub both. PCGamingWiki documents both
# paths under "Skip intro video".
#
# fh5-optiscaler: drop OptiScaler v0.9.1 + a hand-written FH5/RDNA3 INI into
# the install dir to enable FSR 4 INT8 on this Navi 32 box. OptiScaler
# intercepts FH5's DLSS/XeSS calls and reroutes them through the bundled
# FFX SDK. Override values + sources live in
# ./optiscaler-fh5-rdna3.ini; keys not listed there fall through to
# OptiScaler's "auto" defaults.
#
# Required one-time per-game setup the user has to do in Steam (the
# in-game upscaler picker has no public API):
# - In-game: switch the Upscaling option from FSR 2.2 to DLSS or XeSS
# (FSR 2 inputs aren't intercepted). Press Insert to open the Opti
# overlay and set the FFX upscaler to FSR 4.
#
# Caveats:
# - OptiScaler.ini is dropped with mode = "init" so in-game overlay edits
# persist. The hand-written template is only written on first apply (or
# after manual deletion). To push a new default into an existing
# install: rm OptiScaler.ini in the FH5 dir, then `systemctl start
# game-mods`. The DLLs and other static assets stay mode = "create" so
# they're updated on every OptiScaler version bump.
# - OptiScaler's installation page warns against use with online games.
# FH5 has no kernel-mode anti-cheat but Playground does server-side
# telemetry. Use at your own risk.
services.gameMods =
let
optiPkg = pkgs.optiscaler;
fromOpti = relpath: {
source = "${optiPkg}/${relpath}";
mode = "create";
};
in
{
enable = true;
mods."fh5-no-intro" = {
steamAppId = 1551360;
files."media/UI/Videos/T10_MS_Combined.bk2".empty = true;
files."media/UI/Videos/hires/T10_MS_Combined.bk2".empty = true;
};
mods."fh5-optiscaler" = {
steamAppId = 1551360;
files = {
# OptiScaler.dll is renamed to dxgi.dll so FH5's DLL search order
# picks it up as the dxgi shim per the OptiScaler FH5 wiki page.
"dxgi.dll" = fromOpti "OptiScaler.dll";
"OptiScaler.ini" = {
source = ./optiscaler-fh5-rdna3.ini;
# init: drop the template once, then leave it alone so the in-game
# overlay can persist user tweaks.
mode = "init";
};
}
// lib.genAttrs [
"D3D12_Optiscaler/D3D12Core.dll"
"amd_fidelityfx_dx12.dll"
"amd_fidelityfx_framegeneration_dx12.dll"
"amd_fidelityfx_upscaler_dx12.dll"
"amd_fidelityfx_vk.dll"
"dlssg_to_fsr3_amd_is_better.dll"
"fakenvapi.dll"
"fakenvapi.ini"
"libxell.dll"
"libxess.dll"
"libxess_dx11.dll"
"libxess_fg.dll"
] fromOpti;
};
};
# Steam launch options + per-app compat-tool pin via steam-config-nix
# (different-name/steam-config-nix). The patcher runs as a system oneshot
# at activation; closeSteam = true ensures Steam is shut down before the
# localconfig.vdf write so Steam can't clobber it on its next exit.
programs.steam.config = {
enable = true;
closeSteam = true;
defaultCompatTool = "GE-Proton";
apps."fh5" = {
id = 1551360;
compatTool = "GE-Proton";
launchOptions.env = {
# OptiScaler FSR 4 INT8 path on this RDNA 3 (Navi 32) box.
# PROTON_FSR4_UPGRADE opts FH5 into Proton's FSR 4 DLL upgrade;
# DXIL_SPIRV_CONFIG fixes the broken visuals the wmma RDNA3 emulation
# path otherwise produces. Source: OptiScaler FSR4 wiki Linux Setup.
PROTON_FSR4_UPGRADE = "1";
DXIL_SPIRV_CONFIG = "wmma_rdna3_workaround";
# vkd3d-proton stutter/crash workaround on this box; remove when a
# future Proton release fixes the upload-hvv path upstream.
VKD3D_CONFIG = "no_upload_hvv";
};
};
};
}