From ad196ea2680b9975b9fb8cbe3bbaab610500cbfd Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Fri, 4 Oct 2024 02:12:25 +0200 Subject: [PATCH 1/2] maintainers: add griffi-gh --- maintainers/maintainer-list.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index fa68e87eb11ad..dc3334bbdcf9d 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -8066,6 +8066,13 @@ githubId = 201997; name = "Eric Seidel"; }; + griffi-gh = { + name = "Alex Prasol"; + email = "prasol258@gmail.com"; + matrix = "@voxel:nyanbinary.rs"; + github = "griffi-gh"; + githubId = 45996170; + }; grimmauld = { name = "Sören Bender"; email = "soeren@benjos.de"; From fae58912e532e694b2208644746ed13782646927 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Fri, 4 Oct 2024 03:51:41 +0200 Subject: [PATCH 2/2] zepp-simulator: init at 2.0.2 --- .../zepp-simulator/0001-force_qemu_x11.patch | 13 ++ pkgs/by-name/ze/zepp-simulator/package.nix | 189 ++++++++++++++++++ 2 files changed, 202 insertions(+) create mode 100644 pkgs/by-name/ze/zepp-simulator/0001-force_qemu_x11.patch create mode 100644 pkgs/by-name/ze/zepp-simulator/package.nix diff --git a/pkgs/by-name/ze/zepp-simulator/0001-force_qemu_x11.patch b/pkgs/by-name/ze/zepp-simulator/0001-force_qemu_x11.patch new file mode 100644 index 0000000000000..f9bd47bf85146 --- /dev/null +++ b/pkgs/by-name/ze/zepp-simulator/0001-force_qemu_x11.patch @@ -0,0 +1,13 @@ +diff --git a/opt/simulator/resources/firmware/start_qemu.sh b/opt/simulator/resources/firmware/start_qemu.sh +index cfdad8b..64fba99 100644 +--- a/opt/simulator/resources/firmware/start_qemu.sh ++++ b/opt/simulator/resources/firmware/start_qemu.sh +@@ -75,6 +75,8 @@ fi + host_os=$(uname -s) + echo "Host OS type : \"$(uname -v)\"." + if [ "$host_os" = "Linux" ]; then ++ export GDK_BACKEND=x11 ++ + qemu_bin="qemu_linux/qemu-system-arm" + check_file_exists "$qemu_bin" + diff --git a/pkgs/by-name/ze/zepp-simulator/package.nix b/pkgs/by-name/ze/zepp-simulator/package.nix new file mode 100644 index 0000000000000..8e7f0d9d9d3e8 --- /dev/null +++ b/pkgs/by-name/ze/zepp-simulator/package.nix @@ -0,0 +1,189 @@ +{ + stdenv, + lib, + fetchurl, + makeWrapper, + makeDesktopItem, + copyDesktopItems, + autoPatchelfHook, + + # Upstream is officialy built with Electron 18 + # (but it works with Electron 24-30 with minor changes, see HACK below) + electron_30, + asar, + dpkg, + + # qemu deps + glib, + libgcc, + libcxx, + zlib, + libepoxy, + libpng, + libaio, + xorg, + libvterm, + vte, + gsasl, + gtk3, + cairo, + gdk-pixbuf, + numactl, + cyrus_sasl, + SDL2, +}: + +let + # CDN links for 2.0.2: + # MacOS: https://upload-cdn.zepp.com/zepp-applet-and-wechat-applet/20240927/ecb6ca54f4dc97a2f91e53358bbb532d.dmg + # Windows: https://upload-cdn.zepp.com/zepp-applet-and-wechat-applet/20240927/9db7ae1c60c26836a447a71a6fb25b3b.exe + # Linux ARM64: https://upload-cdn.zepp.com/zepp-applet-and-wechat-applet/20240927/02ec69e6a2f3b744d964fd7ba4f40fc3.deb + # Linux AMD64: https://upload-cdn.zepp.com/zepp-applet-and-wechat-applet/20240927/3e688d423cd0cd31a8a589b8325a309e.deb + srcs = { + x86_64-linux = { + url = "https://upload-cdn.zepp.com/zepp-applet-and-wechat-applet/20240927/3e688d423cd0cd31a8a589b8325a309e.deb"; + sha256 = "sha256-ZHqaEL8FoSnRtuqGWpTyJka7D0dHtRADZthq8DG2k24="; + }; + aarch64-linux = { + url = "https://upload-cdn.zepp.com/zepp-applet-and-wechat-applet/20240927/02ec69e6a2f3b744d964fd7ba4f40fc3.deb"; + sha256 = "sha256-J5Y4wLiFOM9D2MIMiRyUtHIZ19rt65ktVCOMZQQwBCI="; + }; + }; + +in + +stdenv.mkDerivation { + pname = "zepp-simulator"; + version = "2.0.2"; + + src = fetchurl srcs.${stdenv.hostPlatform.system}; + + patches = [ + # Fix for qemu input grab not working with NIXOS_OZONE_WL=1 + ./0001-force_qemu_x11.patch + ]; + + nativeBuildInputs = [ + autoPatchelfHook + copyDesktopItems + makeWrapper + + dpkg + asar + + # QEMU deps (runtime): + glib + libgcc + libcxx + zlib + libepoxy + libpng + libaio + xorg.libX11 + libvterm + vte + gsasl + numactl + cyrus_sasl + gtk3 + cairo + gdk-pixbuf + SDL2 + ]; + + dontBuild = true; + + unpackPhase = '' + runHook preUnpack + + dpkg-deb -x $src . + + runHook postUnpack + ''; + + installPhase = '' + runHook preInstall + + # Create output file strucure + mkdir -p $out/{bin,opt,share} + cp -r opt/simulator $out/opt + cp -r usr/share/icons $out/share + + # Remove unnecessary files + rm -rf \ + $out/usr/share/applications/simulator.desktop \ + $out/opt/simulator/*.so \ + $out/opt/simulator/libvulkan.so.1 \ + $out/opt/simulator/swiftshader \ + $out/opt/simulator/simulator \ + $out/opt/simulator/resources/firmware/setup_for_linux.sh + + # De-vendor the qemu binary + # XXX: DO NOT DO THIS + # As stated by @silver.zepp, it's modified and proprietary + # === + # rm -r $out/opt/simulator/resources/firmware/qemu_linux/lib/ + # ln -sf bin/qemu-system-arm $out/opt/simulator/resources/firmware/qemu_linux/qemu-system-arm + + # Use system electron + makeWrapper ${electron_30}/bin/electron $out/bin/simulator \ + --add-flags "--no-sandbox" \ + --add-flags $out/opt/simulator/resources/app.asar \ + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" + + # HACK: disable sandbox introduced in Electron 20 + asar extract $out/opt/simulator/resources/app.asar app_unpacked + rm $out/opt/simulator/resources/app.asar + sed -i \ + 's|contextIsolation: false,|contextIsolation: false, sandbox: false,|g' \ + app_unpacked/build/electron/process/side-service.js + asar pack app_unpacked $out/opt/simulator/resources/app.asar + rm -rf app_unpacked + + runHook postInstall + ''; + + # ignore missing libsasl2.so.2 + autoPatchelfIgnoreMissingDeps = true; + + # HACK: Replace libsasl2.so.2 with libsasl2.so.3 + postFixup = '' + patchelf \ + --replace-needed libsasl2.so.2 libsasl2.so.3 \ + $out/opt/simulator/resources/firmware/qemu_linux/qemu-system-arm + chmod +x $out/opt/simulator/resources/firmware/qemu_linux/qemu-system-arm + ''; + + desktopItems = [ + (makeDesktopItem { + name = "simulator"; + genericName = "Simulator"; + desktopName = "Zepp OS Simulator"; + comment = "Zepp OS Simulator"; + noDisplay = false; + icon = "simulator"; + tryExec = "simulator"; + exec = "simulator %U"; + startupWMClass = "simulator"; + categories = [ + "Application" + "Development" + ]; + mimeTypes = [ "x-scheme-handler/zepp" ]; + }) + ]; + + meta = { + description = "Zepp OS Simulator"; + homepage = "https://developer.zepp.com/os/home"; + license = lib.licenses.unfree; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + # TODO Darwin + platforms = [ + "x86_64-linux" + "aarch64-linux" + ]; + maintainers = with lib.maintainers; [ griffi-gh ]; + mainProgram = "simulator"; + }; +}