49 # zerocallusedregs hardening breaks WeChat
50 glibcWithoutHardening = stdenv.cc.libc.overrideAttrs (old: {
51 hardeningDisable = (old.hardeningDisable or [ ]) ++ [ "zerocallusedregs" ];
54 wechat-uos-env = stdenvNoCC.mkDerivation {
56 name = "wechat-uos-env";
60 mkdir -p $out/usr/share
64 ln -s ${wechat}/opt/* $out/opt/
66 preferLocalBuild = true;
69 wechat-uos-runtime = with xorg; [
70 # Make sure our glibc without hardening gets picked up first
71 (lib.hiPrio glibcWithoutHardening)
133 sources = import ./sources.nix;
135 wechat = stdenvNoCC.mkDerivation
137 pname = "wechat-uos";
138 version = sources.version;
141 x86_64-linux = fetchurl {
142 url = sources.amd64_url;
143 hash = sources.amd64_hash;
145 aarch64-linux = fetchurl {
146 url = sources.arm64_url;
147 hash = sources.arm64_hash;
149 loongarch64-linux = fetchurl {
150 url = sources.loongarch64_url;
151 hash = sources.loongarch64_hash;
153 }.${stdenv.system} or (throw "${pname}-${version}: ${stdenv.system} is unsupported.");
155 nativeBuildInputs = [ dpkg ];
160 dpkg -x $src ./wechat-uos
165 # Use ln for license to prevent being garbage collection
170 cp -r wechat-uos/* $out
176 description = "Messaging app";
177 homepage = "https://weixin.qq.com/";
178 license = licenses.unfree;
179 platforms = [ "x86_64-linux" "aarch64-linux" "loongarch64-linux" ];
180 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
181 maintainers = with maintainers; [ pokon548 xddxdd ];
182 mainProgram = "wechat-uos";
187 inherit (wechat) name meta;
188 runScript = writeShellScript "wechat-uos-launcher" ''
189 export QT_QPA_PLATFORM=xcb
190 export QT_AUTO_SCREEN_SCALE_FACTOR=1
191 export LD_LIBRARY_PATH=${lib.makeLibraryPath wechat-uos-runtime}
193 if [[ ''${XMODIFIERS} =~ fcitx ]]; then
194 export QT_IM_MODULE=fcitx
195 export GTK_IM_MODULE=fcitx
196 elif [[ ''${XMODIFIERS} =~ ibus ]]; then
197 export QT_IM_MODULE=ibus
198 export GTK_IM_MODULE=ibus
199 export IBUS_USE_PORTAL=1
202 ${wechat.outPath}/opt/apps/com.tencent.wechat/files/wechat
204 extraInstallCommands = ''
205 mkdir -p $out/share/applications
206 mkdir -p $out/share/icons
207 cp -r ${wechat.outPath}/opt/apps/com.tencent.wechat/entries/applications/com.tencent.wechat.desktop $out/share/applications
208 cp -r ${wechat.outPath}/opt/apps/com.tencent.wechat/entries/icons/* $out/share/icons/
210 mv $out/bin/$name $out/bin/wechat-uos
212 substituteInPlace $out/share/applications/com.tencent.wechat.desktop \
213 --replace-quiet 'Exec=/usr/bin/wechat' "Exec=$out/bin/wechat-uos --"
215 targetPkgs = pkgs: [ wechat-uos-env ];
217 passthru.updateScript = ./update.sh;
219 extraOutputsToInstall = [ "usr" "var/lib/uos" "var/uos" "etc" ];