From 829c862e73c91cf647426a46f194ac2c1cbbbe71 Mon Sep 17 00:00:00 2001 From: Youwes09 Date: Sat, 21 Feb 2026 17:39:14 -0600 Subject: [PATCH] [BETA] Appimage Workflow V2 --- .github/workflows/build-appimage.yml | 6 +- flake.lock | 89 ++++++++++++++++++++++++++++ flake.nix | 32 +++++++--- src-tauri/tauri.conf.json | 4 +- 4 files changed, 120 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-appimage.yml b/.github/workflows/build-appimage.yml index 2d66e36..ca2f30a 100644 --- a/.github/workflows/build-appimage.yml +++ b/.github/workflows/build-appimage.yml @@ -19,8 +19,12 @@ jobs: - name: Install system dependencies run: | sudo apt-get update + # Pin webkit to 2.44 — 2.46+ causes EGL_BAD_PARAMETER crash on many systems + # https://github.com/gitbutlerapp/gitbutler/issues/5282 sudo apt-get install -y \ - libwebkit2gtk-4.1-dev \ + libwebkit2gtk-4.1-dev=2.44.* \ + libjavascriptcoregtk-4.1-dev=2.44.* \ + gir1.2-webkit2-4.1=2.44.* \ libgtk-3-dev \ libayatana-appindicator3-dev \ librsvg2-dev \ diff --git a/flake.lock b/flake.lock index 896735e..f2895c9 100644 --- a/flake.lock +++ b/flake.lock @@ -15,6 +15,22 @@ "type": "github" } }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1733328505, + "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -33,6 +49,46 @@ "type": "github" } }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nix-appimage": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1757920913, + "narHash": "sha256-jd0QwCVz4O1sHHkeaZILD/7D6oyalceEJ4EFnWCgm0k=", + "owner": "ralismark", + "repo": "nix-appimage", + "rev": "7946addbc0d97e358a6d7aefe5e82310f0fe6b18", + "type": "github" + }, + "original": { + "owner": "ralismark", + "repo": "nix-appimage", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1771369470, @@ -64,11 +120,29 @@ "type": "github" } }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1751274312, + "narHash": "sha256-/bVBlRpECLVzjV19t5KMdMFWSwKLtb5RyXdjz3LJT+g=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "50ab793786d9de88ee30ec4e4c24fb4236fc2674", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "crane": "crane", "flake-parts": "flake-parts", + "nix-appimage": "nix-appimage", "nixpkgs": "nixpkgs", + "nixpkgs-stable": "nixpkgs-stable", "rust-overlay": "rust-overlay" } }, @@ -91,6 +165,21 @@ "repo": "rust-overlay", "type": "github" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 9df2f32..3ee9f22 100644 --- a/flake.nix +++ b/flake.nix @@ -9,10 +9,14 @@ url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; + nix-appimage = { + url = "github:ralismark/nix-appimage"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = - inputs@{ flake-parts, crane, rust-overlay, ... }: + inputs@{ flake-parts, crane, rust-overlay, nix-appimage, ... }: flake-parts.lib.mkFlake { inherit inputs; } { systems = [ "x86_64-linux" @@ -51,8 +55,6 @@ gsettings-desktop-schemas ]; - # Only rebuild the frontend when files that actually affect the output change. - # Changing flake.nix, README.md, src-tauri/*, etc. won't invalidate the cache. frontendSrc = lib.cleanSourceWith { src = ./.; filter = path: type: @@ -94,8 +96,6 @@ installPhase = "cp -r dist $out"; }; - # tauri::generate_context!() embeds icons and reads tauri.conf.json + - # capabilities at compile time — all must survive the source filter. cargoSrc = lib.cleanSourceWith { src = ./src-tauri; filter = path: type: @@ -118,9 +118,6 @@ wrapGAppsHook3 ]; - # Crane unpacks source to /build/source (src-tauri/). - # tauri.conf.json has frontendDist = "../dist", so dist goes one - # level up at /build/dist. preBuild = '' cp -r ${frontend} ../dist ''; @@ -133,6 +130,8 @@ moku = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; + meta.mainProgram = "moku"; + postInstall = '' wrapProgram $out/bin/moku \ --prefix XDG_DATA_DIRS : "${lib.makeSearchPath "share/gsettings-schemas" [ @@ -149,6 +148,7 @@ packages = { inherit moku frontend; default = moku; + appimage = nix-appimage.bundlers."${system}".default moku; }; devShells.default = pkgs.mkShell { @@ -161,13 +161,29 @@ nodejs_22 pnpm suwayomi-server + xdg-utils ]; shellHook = '' export WEBKIT_DISABLE_COMPOSITING_MODE=1 + export APPIMAGE_EXTRACT_AND_RUN=1 + export NO_STRIP=true export PKG_CONFIG_PATH="${pkgs.openssl.dev}/lib/pkgconfig''${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" export XDG_DATA_DIRS="${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}''${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}" + if [ ! -e /usr/bin/xdg-open ]; then + sudo ln -sf ${pkgs.xdg-utils}/bin/xdg-open /usr/bin/xdg-open + fi + + LINUXDEPLOY="$HOME/.cache/tauri/linuxdeploy-x86_64.AppImage" + LINUXDEPLOY_REAL="$HOME/.cache/tauri/linuxdeploy-x86_64.AppImage.real" + if [ -f "$LINUXDEPLOY" ] && [ ! -f "$LINUXDEPLOY_REAL" ]; then + mv "$LINUXDEPLOY" "$LINUXDEPLOY_REAL" + printf '#!/bin/sh\nexec ${pkgs.appimage-run}/bin/appimage-run "%s" "$@"\n' "$LINUXDEPLOY_REAL" > "$LINUXDEPLOY" + chmod +x "$LINUXDEPLOY" + echo "linuxdeploy wrapped with appimage-run" + fi + echo "Moku dev shell" echo " pnpm install && pnpm tauri:dev" ''; diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index e05174e..02a7e5b 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -26,7 +26,7 @@ }, "bundle": { "active": true, - "targets": "all", + "targets": ["appimage"], "icon": [ "icons/32x32.png", "icons/128x128.png", @@ -40,4 +40,4 @@ "open": true } } -} \ No newline at end of file +}