* 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>
4.0 KiB
Mihomo
Native mihomo core + metacubexd dashboard, replacing the Clash Verge GUI. Enable per host with
modules.networking.mihomo.enable = true (ai, shoukei).
Usage
cp sources.example.yaml ~/.config/mihomo/sources.yaml && chmod 600 ~/.config/mihomo/sources.yaml
$EDITOR ~/.config/mihomo/sources.yaml # fill in: secret, private_domains, providers
nu generate.nu # -> ~/.config/mihomo/config.yaml, mode 0600
mihomo -t -f ~/.config/mihomo/config.yaml # validate before restarting
sudo systemctl restart mihomo.service # dashboard: http://127.0.0.1:9090/ui
sources.yaml holds everything private (subscription URLs, secret, private domains) and stays out
of the repo and the Nix store; the module loads config.yaml via LoadCredential. Generate the
config before enabling the module, or the service will not start.
Files
| File | Role |
|---|---|
default.nix |
the service: services.mihomo + TUN + metacubexd |
policy.yaml |
portable routing policy: ads, CN services, local ranges, tail |
generate.nu |
renders config.yaml from sources.yaml + policy.yaml |
sources.example.yaml |
schema for sources.yaml |
Rule order: private_domains, your rules, imported rules, then policy.yaml, ending in MATCH.
Why generate
proxy-provider imports proxies only — a subscription's rules and groups are dropped by the core.
The portable policy is therefore written once in policy.yaml as GEOSITE categories. Provider-bound
policy is opt-in: rules_from: (a decoded snapshot) or file: carry groups, rules and
rule-providers over. The generator drops and reports malformed rules, misplaced MATCH and orphaned
targets instead of writing a config the core rejects.
Gotchas
ipv6: false: nodes without IPv6 egress + AAAA = routing black hole (WeChat/JD/Taobao images); mihomo's IPv6 fake-ip also hung ssh/git locally for ~2 minutes, so it stays off.private_domains: each entry becomes a DIRECT rule + afake-ip-filterentry.- WeChat/QQ media go over bare CDN IPs, hence
multimedia.nt.qq.com.cninfake-ip-filter. If media still stalls:tun_exclude_process: [wechat, WeChatAppEx, qq](Linux names; the fix that won clash-verge-rev#1762). find-process-mode: offunlessPROCESS-*rules ortun_exclude_processneed it.- Rule payloads are bare domains:
DOMAIN-SUFFIX,https://qlogo.cnis invalid. - On a systemd-resolved host, sing-tun normally points resolved at the TUN DNS with
resolvectl. The nixpkgsDynamicUsersandbox cannot make those privileged D-Bus changes, so resolved's own upstream queries bypassdns-hijack any:53and leave via the NIC. Tie a resolver takeover to the service lifetime (resolvectl dns/revertinExecStartPost/ExecStopPost, seehosts/idols-ai/default.nix), prefixed with+to run outside the unit sandbox. Never set link DNS statically to mihomo: a dead mihomo would take DNS down with it, and resolved does not fall back.
References
- clash-verge-rev#1762 — WeChat media under TUN: fake-ip-filter, qlogo/qpic, the exclude-process fix.
- WeChat-under-TUN retrospective — the IPv6 black hole logic; JD and Taobao break the same way.
- mihomo wiki, proxy providers — why subscription rules are dropped.
- meta-rules-dat — the GEOSITE/GEOIP data.
- metacubexd — the dashboard.
- nixpkgs mihomo module
—
DynamicUser,LoadCredential, onlyCAP_NET_ADMINundertunMode.