Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

Seanaye/fix/app image (#7963)

Sean Aye5efb3be36699
diff --git a/nix/appimage/.gitignore b/nix/appimage/.gitignore
new file mode 100644
index 0000000000..c18dd8d83c
--- /dev/null
+++ b/nix/appimage/.gitignore
@@ -0,0 +1 @@
+__pycache__/
diff --git a/nix/appimage/ldd.py b/nix/appimage/ldd.py
new file mode 100755
index 0000000000..cc4fb53e31
--- /dev/null
+++ b/nix/appimage/ldd.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python3
+"""Resolve the full ELF dependency graph for linuxdeploy without executing it."""
+
+import os
+import subprocess
+import sys
+from pathlib import Path
+
+
+def elf_field(binary, field):
+ return subprocess.check_output(
+ ["patchelf", f"--print-{field}", str(binary)], text=True
+ ).strip()
+
+
+def resolve(binary, needed):
+ if needed.startswith("/"):
+ path = Path(needed)
+ return path if path.is_file() else None
+
+ origin = str(binary.resolve().parent)
+ rpath = elf_field(binary, "rpath")
+ paths = rpath.split(":") + os.environ.get("LD_LIBRARY_PATH", "").split(":")
+ paths += ["/lib", "/usr/lib", "/lib64", "/usr/lib64"]
+ for entry in paths:
+ if not entry:
+ continue
+ entry = entry.replace("${ORIGIN}", origin).replace("$ORIGIN", origin)
+ candidate = Path(entry) / needed
+ if candidate.is_file():
+ # Keep the SONAME alias. Resolving symlinks here makes linuxdeploy
+ # copy libfoo.so.1.2 without the libfoo.so.1 name its callers need.
+ return candidate.absolute()
+ return None
+
+
+def dependencies(binary):
+ queue = [Path(binary)]
+ visited = set()
+ result = {}
+ for current in queue:
+ real = current.resolve()
+ if real in visited:
+ continue
+ visited.add(real)
+ for needed in elf_field(current, "needed").splitlines():
+ # Like the loader, reuse the first loaded SONAME. Nix closures may
+ # contain multiple build variants of the same ABI (e.g. libwebp).
+ if needed in result:
+ continue
+ resolved = resolve(current, needed)
+ if resolved is None:
+ raise RuntimeError(f"{current}: {needed} => not found")
+ result[needed] = resolved
+ queue.append(resolved)
+ return result
+
+
+if __name__ == "__main__":
+ try:
+ for name, path in dependencies(sys.argv[1]).items():
+ print(f"\t{name} => {path} (0x0000000000000000)")
+ except (RuntimeError, subprocess.CalledProcessError) as error:
+ print(error, file=sys.stderr)
+ sys.exit(1)
diff --git a/nix/appimage/relocate.py b/nix/appimage/relocate.py
new file mode 100755
index 0000000000..47aa3c886b
--- /dev/null
+++ b/nix/appimage/relocate.py
@@ -0,0 +1,123 @@
+#!/usr/bin/env python3
+"""Finalize linuxdeploy's AppDir before the output plugin creates the squashfs."""
+
+import os
+import re
+import stat
+import subprocess
+import sys
+from pathlib import Path
+
+
+def patchelf(path, *args):
+ return subprocess.check_output(["patchelf", *args, str(path)], text=True).strip()
+
+
+def elf_files(root):
+ for path in sorted(root.rglob("*")):
+ if path.is_symlink() or not path.is_file():
+ continue
+ with path.open("rb") as stream:
+ if stream.read(4) == b"\x7fELF":
+ yield path
+
+
+def relocate(appdir):
+ appdir = Path(appdir).resolve()
+ libdir = appdir / "usr/lib"
+ dynamic = []
+ for path in elf_files(appdir):
+ # AppImage's static launcher has no dynamic section.
+ result = subprocess.run(
+ ["patchelf", "--print-needed", str(path)],
+ capture_output=True,
+ text=True,
+ check=False,
+ )
+ if result.returncode:
+ continue
+ # Tauri's additional files retain read-only Nix store permissions.
+ path.chmod(path.stat().st_mode | stat.S_IWUSR)
+ dynamic.append((path, result.stdout.splitlines()))
+ soname = patchelf(path, "--print-soname")
+ if soname:
+ if "/" in soname:
+ raise RuntimeError(f"invalid SONAME {soname!r}: {path}")
+ alias = path.with_name(soname)
+ if alias.exists() or alias.is_symlink():
+ if alias.resolve() != path.resolve():
+ raise RuntimeError(f"conflicting SONAME {soname}: {alias}, {path}")
+ else:
+ alias.symlink_to(path.name)
+
+ for path, needed in dynamic:
+ for name in needed:
+ if name.startswith("/nix/store/"):
+ basename = Path(name).name
+ if not (libdir / basename).is_file():
+ raise RuntimeError(f"unbundled absolute dependency {name}: {path}")
+ patchelf(path, "--replace-needed", name, basename)
+
+ # Every library needs its own RUNPATH: DT_RUNPATH is not inherited by
+ # transitive dependencies (including GIO modules and WebKit helpers).
+ relative_lib = os.path.relpath(libdir, path.parent)
+ rpaths = ["$ORIGIN"]
+ if relative_lib != ".":
+ rpaths.append(f"$ORIGIN/{relative_lib}")
+ for entry in patchelf(path, "--print-rpath").split(":"):
+ if entry.startswith(("$ORIGIN", "${ORIGIN}")) and entry not in rpaths:
+ rpaths.append(entry)
+ patchelf(path, "--set-rpath", ":".join(rpaths))
+
+ interpreter = subprocess.run(
+ ["patchelf", "--print-interpreter", str(path)],
+ capture_output=True,
+ text=True,
+ check=False,
+ ).stdout.strip()
+ if interpreter.startswith("/nix/store/"):
+ if Path(interpreter).name != "ld-linux-x86-64.so.2":
+ raise RuntimeError(f"unexpected interpreter {interpreter}: {path}")
+ patchelf(path, "--set-interpreter", "/lib64/ld-linux-x86-64.so.2")
+
+ if path.name.startswith("libwebkit2gtk-"):
+ # Release WebKit ignores WEBKIT_EXEC_PATH. Tauri's AppRun changes
+ # cwd to AppDir/usr, and its upstream GTK plugin likewise patches
+ # compiled-in absolute paths to relative ones. Keep ELF offsets
+ # unchanged by NUL-padding the replacement PKGLIBEXECDIR string.
+ contents = path.read_bytes()
+ relocated = re.sub(
+ rb"/nix/store/[^/\x00]+/libexec/webkit2gtk-4\.1\x00",
+ lambda match: b"./bin\x00".ljust(len(match[0]), b"\x00"),
+ contents,
+ )
+ if contents != relocated:
+ path.write_bytes(relocated)
+
+ # Tauri copies Nix's xdg-utils scripts verbatim. Their build-time shebangs
+ # must not leak into the distributable image either.
+ for path in (appdir / "usr/bin").iterdir():
+ if path.is_symlink() or not path.is_file():
+ continue
+ with path.open("rb") as stream:
+ first = stream.readline(256)
+ if first.startswith(b"#!/nix/store/"):
+ shell = first.decode().strip().rsplit("/", 1)[-1]
+ if shell not in ("sh", "bash"):
+ raise RuntimeError(f"unexpected Nix shebang: {path}: {first!r}")
+ content = path.read_bytes()
+ path.chmod(path.stat().st_mode | stat.S_IWUSR)
+ path.write_bytes(
+ f"#!/usr/bin/env {shell}\n".encode() + content[len(first) :]
+ )
+
+ # Fail the build rather than silently shipping another Nix-only ELF.
+ for path, _ in dynamic:
+ for field in ("needed", "rpath"):
+ if "/nix/store/" in patchelf(path, f"--print-{field}"):
+ raise RuntimeError(f"unrelocated {field}: {path}")
+ print(f"Relocated {len(dynamic)} ELF files in {appdir}")
+
+
+if __name__ == "__main__":
+ relocate(sys.argv[1])
diff --git a/nix/appimage/test_packaging.py b/nix/appimage/test_packaging.py
new file mode 100644
index 0000000000..d4f0b38e4e
--- /dev/null
+++ b/nix/appimage/test_packaging.py
@@ -0,0 +1,185 @@
+"""Small real-ELF regression fixtures; no frontend or Rust build required."""
+
+import os
+import shutil
+import subprocess
+import tempfile
+import unittest
+from pathlib import Path
+from unittest.mock import patch
+
+from ldd import dependencies
+from relocate import patchelf, relocate
+
+
+class PackagingTest(unittest.TestCase):
+ def setUp(self):
+ self.temp = tempfile.TemporaryDirectory()
+ self.addCleanup(self.temp.cleanup)
+ self.root = Path(self.temp.name)
+ self.lib = self.root / "build/lib"
+ self.lib.mkdir(parents=True)
+ self.appdir = self.root / "Macro.AppDir"
+ self.bundle_lib = self.appdir / "usr/lib"
+ self.bundle_lib.mkdir(parents=True)
+ (self.appdir / "usr/bin").mkdir()
+ self.environment = patch.dict(os.environ, {"LD_LIBRARY_PATH": ""})
+ self.environment.start()
+ self.addCleanup(self.environment.stop)
+
+ self.second = self.compile(
+ "libsecond.so.2.3", "int second(void) { return 0; }", []
+ )
+ patchelf(self.second, "--set-soname", "libsecond.so.2")
+ self.alias = self.lib / "libsecond.so.2"
+ self.alias.symlink_to(self.second.name)
+ self.first = self.compile(
+ "libfirst.so.1.2",
+ "extern int second(void); int first(void) { return second(); }",
+ [str(self.alias)],
+ )
+ patchelf(self.first, "--set-soname", "libfirst.so.1")
+ self.app = self.compile(
+ "app",
+ "extern int first(void); void _start(void) { first(); }",
+ [str(self.first)],
+ )
+ (self.lib / "libfirst.so.1").symlink_to(self.first.name)
+
+ def compile(self, name, source, libraries):
+ output = self.lib / name
+ link_mode = [] if name == "app" else ["-shared"]
+ subprocess.run(
+ [
+ os.environ.get("CC", "cc"),
+ *link_mode,
+ "-fPIC",
+ "-nostdlib",
+ "-x",
+ "c",
+ "-",
+ "-x",
+ "none",
+ *libraries,
+ f"-Wl,-rpath,{self.lib}",
+ "-o",
+ str(output),
+ ],
+ input=source,
+ text=True,
+ check=True,
+ )
+ return output
+
+ def populate(self):
+ for path in (self.first, self.second):
+ shutil.copy2(path, self.bundle_lib / path.name)
+ shutil.copy2(self.app, self.appdir / "usr/bin/app")
+
+ def test_ldd_includes_transitive_dependencies_and_keeps_aliases(self):
+ result = dependencies(self.app)
+ self.assertEqual(set(result), {"libfirst.so.1", "libsecond.so.2"})
+ self.assertEqual(result["libsecond.so.2"], self.alias)
+
+ def test_ldd_rejects_missing_transitive_dependency(self):
+ self.alias.unlink()
+ with self.assertRaisesRegex(RuntimeError, "libsecond.so.2 => not found"):
+ dependencies(self.app)
+
+ def test_ldd_handles_cycles(self):
+ patchelf(self.second, "--add-needed", "libfirst.so.1")
+ self.assertEqual(len(dependencies(self.app)), 2)
+
+ def test_ldd_reuses_first_loaded_soname(self):
+ alternate = self.root / "alternate"
+ alternate.mkdir()
+ shutil.copy2(self.second, alternate / "libsecond.so.2")
+ patchelf(self.first, "--set-rpath", str(alternate))
+ patchelf(self.app, "--add-needed", "libsecond.so.2")
+ result = dependencies(self.app)
+ self.assertEqual(result["libsecond.so.2"], self.alias)
+
+ def test_relocation_restores_sonames_and_origin_paths(self):
+ self.populate()
+ relocate(self.appdir)
+ self.assertEqual(
+ (self.bundle_lib / "libsecond.so.2").readlink(), Path(self.second.name)
+ )
+ binary = self.appdir / "usr/bin/app"
+ self.assertEqual(patchelf(binary, "--print-rpath"), "$ORIGIN:$ORIGIN/../lib")
+ self.assertEqual(
+ patchelf(self.bundle_lib / self.first.name, "--print-rpath"), "$ORIGIN"
+ )
+ self.assertEqual(len(dependencies(binary)), 2)
+ relocate(self.appdir) # Idempotent; never create links to links.
+
+ def test_relocation_rewrites_absolute_needed(self):
+ self.populate()
+ binary = self.appdir / "usr/bin/app"
+ absolute = "/nix/store/fixture/lib/libfirst.so.1"
+ patchelf(binary, "--replace-needed", "libfirst.so.1", absolute)
+ relocate(self.appdir)
+ self.assertEqual(patchelf(binary, "--print-needed"), "libfirst.so.1")
+
+ def test_relocation_rejects_unbundled_absolute_needed(self):
+ self.populate()
+ binary = self.appdir / "usr/bin/app"
+ patchelf(binary, "--add-needed", "/nix/store/fixture/lib/libmissing.so.1")
+ with self.assertRaisesRegex(RuntimeError, "unbundled absolute dependency"):
+ relocate(self.appdir)
+
+ def test_relocation_rewrites_interpreter_and_shebang(self):
+ self.populate()
+ binary = self.appdir / "usr/bin/app"
+ patchelf(
+ binary, "--set-interpreter", "/nix/store/fixture/lib/ld-linux-x86-64.so.2"
+ )
+ script = self.appdir / "usr/bin/xdg-open"
+ script.write_text("#!/nix/store/fixture/bin/sh\necho ok\n")
+ relocate(self.appdir)
+ self.assertEqual(
+ patchelf(binary, "--print-interpreter"), "/lib64/ld-linux-x86-64.so.2"
+ )
+ self.assertEqual(script.read_text(), "#!/usr/bin/env sh\necho ok\n")
+
+ def test_relocation_handles_read_only_nix_copies(self):
+ self.populate()
+ for path in self.bundle_lib.iterdir():
+ path.chmod(0o555)
+ script = self.appdir / "usr/bin/xdg-open"
+ script.write_text("#!/nix/store/fixture/bin/sh\necho ok\n")
+ script.chmod(0o555)
+ relocate(self.appdir)
+ self.assertEqual(
+ patchelf(self.bundle_lib / self.first.name, "--print-rpath"), "$ORIGIN"
+ )
+ self.assertTrue(script.read_text().startswith("#!/usr/bin/env sh\n"))
+
+ def test_relocation_rewrites_release_webkit_helper_directory(self):
+ self.populate()
+ prefix = b"/nix/store/fixture/libexec/webkit2gtk-4.1"
+ webkit = self.compile(
+ "libwebkit2gtk-4.1.so.0",
+ f'const char helper_directory[] = "{prefix.decode()}";',
+ [],
+ )
+ bundled = self.bundle_lib / webkit.name
+ shutil.copy2(webkit, bundled)
+ relocate(self.appdir)
+ self.assertNotIn(prefix, bundled.read_bytes())
+ self.assertIn(b"./bin\x00", bundled.read_bytes())
+ self.assertEqual(patchelf(bundled, "--print-rpath"), "$ORIGIN")
+ before = bundled.read_bytes()
+ relocate(self.appdir)
+ self.assertEqual(bundled.read_bytes(), before)
+
+ def test_relocation_rejects_conflicting_sonames(self):
+ self.populate()
+ conflicting = self.bundle_lib / "conflicting.so"
+ shutil.copy2(self.first, conflicting)
+ with self.assertRaisesRegex(RuntimeError, "conflicting SONAME"):
+ relocate(self.appdir)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/nix/tauri-desktop.nix b/nix/tauri-desktop.nix
index 1b17be1b4f..b3fd4fc948 100644
--- a/nix/tauri-desktop.nix
+++ b/nix/tauri-desktop.nix
@@ -44,7 +44,11 @@
let
rel = lib.removePrefix ((toString jsRoot) + "/") (toString path);
in
- !(lib.hasPrefix "node_modules/" rel)
+ # Packaging helpers are separate derivation inputs, not frontend or
+ # WASM sources. Avoid recompiling both for AppImage-only changes.
+ rel != "nix"
+ && !(lib.hasPrefix "nix/" rel)
+ && !(lib.hasPrefix "node_modules/" rel)
&& !(lib.hasPrefix "apps/web/node_modules/" rel)
&& !(lib.hasPrefix "apps/web/dist/" rel)
&& !(lib.hasPrefix "apps/web/tauri/target/" rel)
@@ -372,6 +376,7 @@
int failed = 0;
if (fputs("#! /usr/bin/env bash\n"
"export APPDIR=\"''${APPDIR:-\"$(dirname \"$(realpath \"$0\")\")\"}\"\n"
+ "export WEBKIT_INJECTED_BUNDLE_PATH=\"$APPDIR/usr/lib\"\n"
"gio_modules=\"$APPDIR/usr/lib/gio/modules\"\n"
"if [ -d \"$gio_modules\" ]; then\n"
" case \":''${GIO_EXTRA_MODULES:-}:\" in\n"
@@ -423,7 +428,19 @@
setenv("PATH", path, 1);
}
- char **args = calloc((size_t)argc + 1, sizeof(char *));
+ // These are loaded at runtime, so ldd on the main binary cannot
+ // discover them. Deploy their dependency graphs as well.
+ const char *runtime_args[] = {
+ "--executable", "${pkgs.webkitgtk_4_1}/libexec/webkit2gtk-4.1/WebKitWebProcess",
+ "--executable", "${pkgs.webkitgtk_4_1}/libexec/webkit2gtk-4.1/WebKitNetworkProcess",
+ "--executable", "${pkgs.webkitgtk_4_1}/libexec/webkit2gtk-4.1/WebKitGPUProcess",
+ "--library", "${pkgs.webkitgtk_4_1}/lib/webkit2gtk-4.1/injected-bundle/libwebkit2gtkinjectedbundle.so",
+ "--library", "${gioTlsModulePath}/libgiognutls.so",
+ "--library", "${gioTlsModulePath}/libgiognomeproxy.so",
+ "--library", "${gioTlsModulePath}/libgiolibproxy.so",
+ };
+ size_t runtime_argc = sizeof(runtime_args) / sizeof(runtime_args[0]);
+ char **args = calloc((size_t)argc + runtime_argc + 1, sizeof(char *));
args[0] = "${pkgs.linuxdeploy}/bin/linuxdeploy";
int out = 1;
for (int i = 1; i < argc; i++) {
@@ -439,6 +456,9 @@
}
args[out++] = argv[i];
}
+ for (size_t i = 0; i < runtime_argc; i++) {
+ args[out++] = (char *)runtime_args[i];
+ }
args[out] = NULL;
execv(args[0], args);
perror("execv linuxdeploy");
@@ -475,10 +495,26 @@
cp -a ${tauriLinuxdeployAppimagePluginExtracted}/. "$out/lib/linuxdeploy-plugin-appimage/"
chmod -R u+w "$out/lib/linuxdeploy-plugin-appimage"
patchShebangs "$out/lib/linuxdeploy-plugin-appimage"
- printf '%s\n' \
- '#!${pkgs.runtimeShell}' \
- 'exec "'$out'/lib/linuxdeploy-plugin-appimage/AppRun" "$@"' \
- > "$out/bin/linuxdeploy-plugin-appimage.AppImage"
+ cat > "$out/bin/linuxdeploy-plugin-appimage.AppImage" <<'EOF'
+ #!${pkgs.runtimeShell}
+ set -euo pipefail
+ args=("$@")
+ appdir=""
+ while [ "$#" -gt 0 ]; do
+ case "$1" in
+ --appdir=*) appdir="''${1#--appdir=}" ;;
+ --appdir) shift; appdir="$1" ;;
+ esac
+ shift
+ done
+ if [ -n "$appdir" ]; then
+ export PATH="${lib.makeBinPath [ pkgs.patchelf ]}:$PATH"
+ ${pkgs.python3}/bin/python3 ${./appimage/relocate.py} "$appdir"
+ fi
+ exec @plugin@ "''${args[@]}"
+ EOF
+ substituteInPlace "$out/bin/linuxdeploy-plugin-appimage.AppImage" \
+ --replace-fail '@plugin@' "$out/lib/linuxdeploy-plugin-appimage/AppRun"
chmod 0755 "$out/bin/linuxdeploy-plugin-appimage.AppImage"
'';
};
@@ -506,6 +542,19 @@
tauriRuntimeClosure = pkgs.closureInfo {
rootPaths = tauriRuntimeLibraries ++ tauri.commonArgs.buildInputs;
};
+ tauriGstreamerPlugins = pkgs.symlinkJoin {
+ name = "tauri-gstreamer-plugins";
+ paths = map lib.getLib (
+ with pkgs.gst_all_1;
+ [
+ gstreamer
+ gst-plugins-base
+ gst-plugins-good
+ gst-plugins-bad
+ gst-libav
+ ]
+ );
+ };
tauriAppImageConfig = builtins.toJSON {
version = appVersion;
plugins = desktopPlugins;
@@ -517,6 +566,7 @@
active = true;
targets = [ "appimage" ];
useLocalToolsDir = true;
+ linux.appimage.bundleMediaFramework = true;
linux.appimage.files = {
"/usr/bin/xdg-mime" = "${pkgs.xdg-utils}/bin/xdg-mime";
"/usr/bin/xdg-open" = "${pkgs.xdg-utils}/bin/xdg-open";
@@ -775,6 +825,26 @@
}
);
+ tauriAppImagePackagingTests =
+ pkgs.runCommand "tauri-appimage-packaging-tests"
+ {
+ nativeBuildInputs = [
+ pkgs.python3
+ pkgs.patchelf
+ pkgs.stdenv.cc
+ ];
+ }
+ ''
+ export PYTHONDONTWRITEBYTECODE=1
+ python3 -m unittest discover -s ${./appimage} -v
+ # GStreamer's default Nix output is bin; its scanner and core plugins
+ # live in the library output. Do not silently ship an empty helper dir.
+ test -x ${lib.getLib pkgs.gst_all_1.gstreamer}/libexec/gstreamer-1.0/gst-plugin-scanner
+ test -f ${tauriGstreamerPlugins}/lib/gstreamer-1.0/libgstcoreelements.so
+ test -f ${tauriGstreamerPlugins}/lib/gstreamer-1.0/libgstapp.so
+ touch "$out"
+ '';
+
tauriDesktopAppImage = craneLib.mkCargoDerivation (
tauri.commonArgs
// {
@@ -792,11 +862,15 @@
pkgs.gnugrep
pkgs.gnused
pkgs.patchelf
+ pkgs.python3
pkgs.which
];
LD_LIBRARY_PATH = tauriRuntimeLibraryPath;
LDAI_RUNTIME_FILE = tauriAppImageRuntime;
+ GSTREAMER_PLUGINS_DIR = "${tauriGstreamerPlugins}/lib/gstreamer-1.0";
+ GSTREAMER_HELPERS_DIR = "${lib.getLib pkgs.gst_all_1.gstreamer}/libexec/gstreamer-1.0";
preBuild = ''
+ test -e ${tauriAppImagePackagingTests}
${tauriDesktopPreBuild}
runtime_library_path="$(while IFS= read -r store_path; do
@@ -812,71 +886,12 @@
install -m 0755 ${tauriLinuxdeployAppimagePlugin}/bin/linuxdeploy-plugin-appimage.AppImage target/.tauri/linuxdeploy-plugin-appimage.AppImage
install -m 0755 ${tauriBundlerSource}/crates/tauri-bundler/src/bundle/linux/appimage/linuxdeploy-plugin-gtk.sh target/.tauri/linuxdeploy-plugin-gtk.sh
install -m 0755 ${tauriBundlerSource}/crates/tauri-bundler/src/bundle/linux/appimage/linuxdeploy-plugin-gstreamer.sh target/.tauri/linuxdeploy-plugin-gstreamer.sh
- cat > target/.tauri/ldd <<'EOF'
- #!${pkgs.runtimeShell}
- set -euo pipefail
-
- binary="''${1:?usage: ldd <elf>}"
- if ! needed=$(patchelf --print-needed "$binary" 2>/dev/null); then
- echo "not a dynamic executable"
- exit 1
- fi
-
- origin=$(cd "$(dirname "$binary")" && pwd -P)
- rpath=$(patchelf --print-rpath "$binary" 2>/dev/null || true)
- search_path=""
- append_search_path() {
- local path_entry="$1"
- [ -n "$path_entry" ] || return 0
- if [ -z "$search_path" ]; then
- search_path="$path_entry"
- else
- search_path="$search_path:$path_entry"
- fi
- }
-
- IFS=: read -r -a rpath_entries <<< "$rpath"
- for entry in "''${rpath_entries[@]}"; do
- entry=$(printf '%s' "$entry" | awk -v origin="$origin" '{ gsub(/\$\{ORIGIN\}/, origin); gsub(/\$ORIGIN/, origin); print }')
- append_search_path "$entry"
- done
- append_search_path "''${LD_LIBRARY_PATH:-}"
- append_search_path "/lib"
- append_search_path "/usr/lib"
- append_search_path "/lib64"
- append_search_path "/usr/lib64"
-
- resolve_needed() {
- local needed_name="$1"
- if [ "''${needed_name#/}" != "$needed_name" ] && [ -e "$needed_name" ]; then
- readlink -f "$needed_name"
- return 0
- fi
-
- local entry candidate
- IFS=: read -r -a search_entries <<< "$search_path"
- for entry in "''${search_entries[@]}"; do
- [ -n "$entry" ] || continue
- candidate="$entry/$needed_name"
- if [ -e "$candidate" ]; then
- readlink -f "$candidate"
- return 0
- fi
- done
-
- return 1
- }
-
- while IFS= read -r needed_name; do
- [ -n "$needed_name" ] || continue
- if resolved=$(resolve_needed "$needed_name"); then
- printf '\t%s => %s (0x0000000000000000)\n' "$needed_name" "$resolved"
- else
- printf '\t%s => not found\n' "$needed_name"
- fi
- done <<< "$needed"
- EOF
- chmod 0755 target/.tauri/ldd
+ # The upstream plugin copies Nix's read-only modes, then immediately
+ # calls patchelf on those copies. Make both libraries and helpers writable.
+ substituteInPlace target/.tauri/linuxdeploy-plugin-gstreamer.sh \
+ --replace-fail 'cp "$i" "$plugins_target_dir"' 'install -m0755 "$i" "$plugins_target_dir"' \
+ --replace-fail 'cp "$i" "$helpers_target_dir"' 'install -m0755 "$i" "$helpers_target_dir"'
+ install -m 0755 ${./appimage/ldd.py} target/.tauri/ldd
patchShebangs target/.tauri/*.sh target/.tauri/ldd target/.tauri/linuxdeploy-plugin-appimage.AppImage
'';
buildPhaseCargoCommand = ''
@@ -901,6 +916,10 @@
);
in
{
+ checks = lib.optionalAttrs isX86_64Linux {
+ tauri-appimage-packaging = tauriAppImagePackagingTests;
+ };
+
apps = lib.optionalAttrs isLinux {
tauri-desktop = {
type = "app";