Files
nix-config/hardening/nixpaks/umu.nix
T
ryan4yin | 二花 b726c28c14 feat(nixpak): sandbox Steam and Heroic in ~/Gaming (#520)
* feat(nixpak): sandbox Steam and Heroic in ~/Gaming

idols-ai stops preserving ~/.local/share/Steam, ~/.steam, ~/.config/heroic
and their game data, which must be moved into ~/Gaming before deploying.

Assisted-by: DeepSeek Harness (deepseek-flash)

* refactor(nixpak): replace steam-fix.nu with sandboxed protontricks

Assisted-by: DeepSeek Harness (claude-opus-5-5)

* fix(nixpak): hide host documents and GTK config from game sandboxes

Assisted-by: DeepSeek Harness (claude-opus-5-5)

* docs(ai): locate the Steam library under ~/Gaming

Assisted-by: DeepSeek Harness (claude-opus-5-5)

* fix(umu-game): confine writes to ~/Gaming and keep foreign entries

Assisted-by: DeepSeek Harness (claude-opus-5-5)

* fix(nixpak): keep Steam and Heroic in the application launcher

The wrappers only carried bin/, so neither launcher had a desktop entry
after replacing programs.steam.

Assisted-by: DeepSeek Harness (deepseek-flash)

* fix(nixpak): give the game sandboxes a fontconfig that sees CJK fonts

Steam rendered Chinese as tofu: the FHS layers build their own /etc/fonts,
whose config lists only DejaVu and the XDG font directory, so neither the
host fonts nor the FHS /usr/share/fonts were ever scanned. Point
FONTCONFIG_FILE at a small config that includes /usr/share/fonts, and ship
WenQuanYi Zen Hei and Noto Sans CJK in all three FHS layers.

Assisted-by: DeepSeek Harness (deepseek-flash)

* fix(nixpak): grant the game launchers a StatusNotifier tray icon

Steam and Heroic register a tray icon over D-Bus, and the game sandboxes
granted no StatusNotifierWatcher access, so the desktop shell had nothing
to show for them. Enable desktopIntegration.tray for all three launchers
and teach the policy suites to expect it.

Assisted-by: DeepSeek Harness (deepseek-flash)

* fix(nixpak): drop the duplicate host CJK font and tidy the font overrides

Steam reads the fonts inside its own FHS layer, so the system-wide wqy_zenhei
added for it no longer serves any sandbox. Give gaming-policy its own comment
for FONTCONFIG_FILE instead of leaving it under the compat-tool one, make the
desktop-base value a default, and note the SNI tray grant in the README table.

Assisted-by: DeepSeek Harness (deepseek-flash)
2026-11-06 02:18:33 -06:00

67 lines
2.0 KiB
Nix

# umu-launcher sandbox for Windows games outside Steam. The launchers that the
# nix-config-umu-game skill writes to ~/Gaming/Games/<name> are game-writable,
# so the host never executes them: `umu-sandbox ~/Games/<name>/run` (a sandbox
# path) runs the whole script, conf and prelaunch included, inside the sandbox.
# `umu-sandbox protontricks <appid> ...` fixes a Steam game's prefix the same way.
{
steam,
umu-launcher-unwrapped,
mangohud,
winetricks,
protontricks,
# Wine draws its dialogs with these; the FHS fontconfig only scans
# /usr/share/fonts (see modules/gaming-policy.nix).
wqy_zenhei,
noto-fonts-cjk-sans,
bbe,
gamescope,
dwproton-bin,
writeShellScript,
mkNixPak,
...
}:
let
appId = "org.openwinecomponents.umu";
# pkgs/by-name/um/umu-launcher, with a generic entry point and the tools the
# generated launchers call.
package = steam.buildRuntimeEnv {
pname = "umu-sandbox";
inherit (umu-launcher-unwrapped) version;
extraPkgs = _: [
umu-launcher-unwrapped
mangohud
winetricks
protontricks
wqy_zenhei
noto-fonts-cjk-sans
bbe
gamescope
];
executableName = "umu-sandbox";
runScript = writeShellScript "umu-sandbox" ''exec "$@"'';
# As upstream: Legendary spawns umu and exits without waiting for it.
dieWithParent = false;
meta = umu-launcher-unwrapped.meta // {
mainProgram = "umu-sandbox";
};
};
wrapped = mkNixPak {
config = {
imports = [ ./modules/gaming-policy.nix ];
app = {
inherit package;
binPath = "bin/umu-sandbox";
};
flatpak = { inherit appId; };
bubblewrap.env = {
# The session's UMU_PROTONPATH does not survive clearEnv; this path
# also tracks every dwproton-bin update.
UMU_PROTONPATH = "${dwproton-bin.steamcompattool}";
# Lets the generated launchers refuse to start outside the sandbox.
UMU_SANDBOX = "1";
};
};
};
in
wrapped.config.script