Files
nix-config-ryan4yin/hardening/nixpaks/qq.nix
T
Ryan Yin 34e984fb92 fix(nixpak): give QQ an X11 connection for its clipboard
QQ copies through the X11 CLIPBOARD even with a Wayland window; without an X server it exited on copy. QQ now shares XWayland's display trust, like WeChat.

Assisted-by: DeepSeek Harness (claude-opus-5-5)
2026-11-06 18:26:17 +08:00

97 lines
2.5 KiB
Nix

# Refer:
# - Flatpak manifest's docs:
# - https://docs.flatpak.org/en/latest/manifests.html
# - https://docs.flatpak.org/en/latest/sandbox-permissions.html
# - QQ's flatpak manifest: https://github.com/flathub/com.qq.QQ/blob/master/com.qq.QQ.yaml
{
lib,
qq,
mkNixPak,
buildEnv,
makeDesktopItem,
...
}:
let
appId = "com.qq.QQ";
wrapped = mkNixPak {
config =
{ sloth, ... }:
{
app = {
package = qq;
binPath = "bin/qq";
};
flatpak.appId = appId;
imports = [
./modules/desktop-base.nix
./modules/network.nix
];
portalGroups = {
fileChooser = true;
openUri = true;
notifications = true;
screenCast = true;
camera = true;
inhibit = true;
inputMethod = true;
};
desktopIntegration = {
notifications = true;
tray = true;
mpris = true;
accessibility = true;
};
bubblewrap = {
# QQ renders through Wayland but still uses the X11 clipboard; like WeChat,
# keep an X11 fallback so copying does not lose its X connection.
sockets.x11 = true;
env = {
DISPLAY = sloth.envOr "DISPLAY" "";
XAUTHORITY = sloth.envOr "XAUTHORITY" (sloth.concat' sloth.homeDir "/.Xauthority");
};
# To trace all the home files QQ accesses, you can use the following nushell command:
# just trace-access qq
# See the Justfile in the root of this repository for more information.
bind.rw = [
sloth.xdgDocumentsDir
sloth.xdgDownloadDir
sloth.xdgMusicDir
sloth.xdgVideosDir
sloth.xdgPicturesDir
];
};
};
};
exePath = lib.getExe wrapped.config.script;
in
buildEnv {
inherit (wrapped.config.script) name meta passthru;
paths = [
wrapped.config.script
(makeDesktopItem {
name = appId;
desktopName = "QQ";
genericName = "QQ Boxed";
comment = "Tencent QQ, also known as QQ, is an instant messaging software service and web portal developed by the Chinese technology company Tencent.";
exec = "${exePath} %U";
terminal = false;
icon = "${qq}/share/icons/hicolor/512x512/apps/qq.png";
startupNotify = true;
startupWMClass = "QQ";
type = "Application";
categories = [
"InstantMessaging"
"Network"
];
extraConfig = {
X-Flatpak = appId;
};
})
];
}