50 # zerocallusedregs hardening breaks WeChat
51 glibcWithoutHardening = stdenv.cc.libc.overrideAttrs (old: {
52 hardeningDisable = (old.hardeningDisable or [ ]) ++ [ "zerocallusedregs" ];
55 wechat-uos-env = stdenvNoCC.mkDerivation {
57 name = "wechat-uos-env";
61 mkdir -p $out/usr/share
65 ln -s ${wechat}/opt/* $out/opt/
67 preferLocalBuild = true;
70 wechat-uos-runtime = with xorg; [
71 # Make sure our glibc without hardening gets picked up first
72 (lib.hiPrio glibcWithoutHardening)
134 sources = import ./sources.nix;
136 wechat = stdenvNoCC.mkDerivation rec {
137 pname = "wechat-uos";
138 version = sources.version;
142 x86_64-linux = fetchurl {
143 url = sources.amd64_url;
144 hash = sources.amd64_hash;
146 aarch64-linux = fetchurl {
147 url = sources.arm64_url;
148 hash = sources.arm64_hash;
150 loongarch64-linux = fetchurl {
151 url = sources.loongarch64_url;
152 hash = sources.loongarch64_hash;
155 .${stdenv.system} or (throw "${pname}-${version}: ${stdenv.system} is unsupported.");
157 nativeBuildInputs = [ dpkg ];
162 dpkg -x $src ./wechat-uos
167 # Use ln for license to prevent being garbage collection
172 cp -r wechat-uos/* $out
178 description = "Messaging app";
179 homepage = "https://weixin.qq.com/";
180 license = licenses.unfree;
186 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
187 maintainers = with maintainers; [
191 mainProgram = "wechat-uos";
196 inherit (wechat) pname version meta;
197 runScript = writeShellScript "wechat-uos-launcher" ''
198 export QT_QPA_PLATFORM=xcb
199 export QT_AUTO_SCREEN_SCALE_FACTOR=1
200 export LD_LIBRARY_PATH=${lib.makeLibraryPath wechat-uos-runtime}
202 if [[ ''${XMODIFIERS} =~ fcitx ]]; then
203 export QT_IM_MODULE=fcitx
204 export GTK_IM_MODULE=fcitx
205 elif [[ ''${XMODIFIERS} =~ ibus ]]; then
206 export QT_IM_MODULE=ibus
207 export GTK_IM_MODULE=ibus
208 export IBUS_USE_PORTAL=1
211 ${wechat.outPath}/opt/apps/com.tencent.wechat/files/wechat
213 extraInstallCommands = ''
214 mkdir -p $out/share/applications
215 mkdir -p $out/share/icons
216 cp -r ${wechat.outPath}/opt/apps/com.tencent.wechat/entries/applications/com.tencent.wechat.desktop $out/share/applications
217 cp -r ${wechat.outPath}/opt/apps/com.tencent.wechat/entries/icons/* $out/share/icons/
219 substituteInPlace $out/share/applications/com.tencent.wechat.desktop \
220 --replace-quiet 'Exec=/usr/bin/wechat' "Exec=$out/bin/wechat-uos --"
222 targetPkgs = pkgs: [ wechat-uos-env ];
224 passthru.updateScript = ./update.sh;
226 extraOutputsToInstall = [