Files
nix-config/modules/nixos/desktop/computer-use.nix
T
ryan4yin | 二花 8f0961d9c2 fix(desktop): tie ai's link DNS takeover to mihomo's lifecycle (#380)
* fix(desktop): tie ai's link DNS takeover to mihomo's lifecycle

sing-tun normally points systemd-resolved at the TUN DNS by running
resolvectl (dns/domain/default-route). Under nixpkgs' hardened
DynamicUser mihomo unit that hand-off fails silently: the unit's
RestrictAddressFamilies blocks resolvectl's D-Bus socket and resolve1
requires privileged authorization, so resolved keeps querying the
physical-link DNS, fake-ip is bypassed, and domain rules degrade to
MATCH.

Do the hand-off as '+' ExecStartPost/ExecStopPost hooks instead: '+'
commands run outside the sandbox (systemd.exec: address-family
restrictions do not apply to them) and ExecStopPost reverts even on
crashes, so a dead mihomo leaves DNS usable.

Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>

* docs(mihomo): record sing-tun's resolvectl hand-off as the leak cause

Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>

* refactor(desktop): keep mihomo only on ai and shoukei

ruby/kana never ran the core (service inactive live), and their
resolved + TUN combo would reintroduce the resolver leak once enabled.
Drop the enable and the explicit module import from computer-use; the
eval test now pins mihomo=false for both guests.

---------

Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>
2026-10-05 00:07:32 +08:00

49 lines
1.3 KiB
Nix

{
config,
lib,
pkgs,
myvars,
...
}:
let
cfg = config.modules.desktop.computerUse;
username = myvars.username;
# Keep the guest timezone consistent with the proxy's exit region. A
# China-based timezone with a US/JP exit IP is a strong automation signal.
timeZone = if cfg.proxyRegion == "jp" then "Asia/Tokyo" else "America/Los_Angeles";
in
{
options.modules.desktop.computerUse = {
enable = lib.mkEnableOption "headless computer-use environment (X11 + desktop automation)";
proxyRegion = lib.mkOption {
type = lib.types.enum [
"us"
"jp"
];
default = "us";
description = "Proxy exit region; keeps the timezone consistent with the egress IP.";
};
};
config = lib.mkIf cfg.enable {
users.users."${username}".linger = true;
# computer-use-linux / cua-driver read the AT-SPI accessibility tree.
services.gnome.at-spi2-core.enable = true;
# A sparse font set is itself a browser fingerprinting signal, so ship the
# same rich font set the desktops use.
modules.desktop.fonts.enable = true;
# Mesa userspace (software GL for X11).
hardware.graphics.enable = true;
# Match the proxy's exit region.
time.timeZone = lib.mkForce timeZone;
# Browsers keep their profile/preferences in dconf.
programs.dconf.enable = true;
};
}