Fix NixOS build: nativeBuildInputs, wrapGAppsHook3, libayatana-appindicator runtime closure#1063
Open
Aypex wants to merge 1 commit intoRightNow-AI:mainfrom
Open
Fix NixOS build: nativeBuildInputs, wrapGAppsHook3, libayatana-appindicator runtime closure#1063Aypex wants to merge 1 commit intoRightNow-AI:mainfrom
Aypex wants to merge 1 commit intoRightNow-AI:mainfrom
Conversation
Four issues prevented a clean nixos-rebuild on NixOS 26.05+ unstable: 1. perl/clang/pkg-config were in buildInputs but openssl-src's build.rs needs them on PATH at compile time → move to nativeBuildInputs. 2. openfang-desktop's GTK app needs wrapGAppsHook3 (renamed from wrapGAppsHook in current nixpkgs) and pkg-config in nativeBuildInputs to discover webkitgtk_4_1.pc and properly wrap runtime env vars. 3. libayatana-appindicator added to desktop buildInputs so the closure includes it. Without it, libappindicator-sys's runtime dlopen fails with 'cannot open shared object file' and the desktop binary panics at tray initialization. 4. preFixup hook injects libayatana-appindicator's lib path into gappsWrapperArgs. Required because the lib is dlopen'd at runtime (no link-time dep), so 'just adding to buildInputs' isn't enough — Nix's reference scanner only sees deps that appear in the binary. The string interpolation forces inclusion in the closure AND wraps LD_LIBRARY_PATH for the dlopen call to succeed. Tested on NixOS 26.05 (nixos-unstable channel) with AMD RX 7900 XTX, Hyprland 0.53+, webkitgtk_4_1, gtk3. Desktop window renders cleanly without any WEBKIT_* fallback env vars.
6 tasks
Member
|
Confirmed this is the right NixOS packaging — Rebase on latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four independent fixes to
flake.nixthat together make a cleannix build .#openfang-cliandnix build .#openfang-desktopwork on NixOS. Each is a real upstream bug, not a NixOS-only quirk — NixOS just surfaces them because it doesn't have system-wide/usr/libas a fallback.Tested on:
main@ current HEADThe desktop window renders cleanly on first launch without any
WEBKIT_*fallback env vars. Kernel boots, 61 skills load, 9 hands register, embedded server binds, default assistant agent spawns, tray initializes.The Four Fixes
1.
perl/clang/pkg-config→nativeBuildInputsBefore:
Symptom on NixOS:
Why: These are build-time tools that
openssl-src'sbuild.rsinvokes during cargo compilation. Nix distinguishesbuildInputs(target/runtime deps, linked into the binary) fromnativeBuildInputs(host-side tools available during the build). Other distros merge these, which is why the bug is invisible on macOS / Debian / Arch —perljust happens to be on$PATH. The fix is adding a siblingnativeBuildInputsdeclaration.2. Desktop crate needs
pkg-config+wrapGAppsHook3innativeBuildInputsSymptom on NixOS:
No package 'webkit2gtk-4.1' foundduring desktop compile; also missing GTK runtime env vars (XDG_DATA_DIRS,GIO_MODULE_DIR, etc.) so file dialogs and icons break at runtime.Why:
wrapGAppsHook3is the standard NixOS pattern for GTK apps — it auto-wraps the resulting binaries with the right env vars. Note it'swrapGAppsHook3, notwrapGAppsHook(renamed in current nixpkgs because GTK4 now has its ownwrapGAppsHook4). Pluspkg-configexplicitly, since the per-cratebuildInputsisn't enough to surface.pcfiles during the webkitgtk discovery step.3.
libayatana-appindicatorin desktopbuildInputsSymptom on NixOS:
Why: The
tray.rsmodule loads this library via runtimedlopen(), not link-time linking. On other distros it's in/usr/lib. On NixOS there's no system-wide/usr/lib, so it must be in the build closure.4.
preFixuphook injectingLD_LIBRARY_PATHfor appindicatorSymptom: Same panic as #3, even after adding
libayatana-appindicatortobuildInputs.Why (this one is subtle): A library only ends up in the Nix runtime closure if the binary actually links against it.
libappindicator-sysuses pure runtimedlopen()with no compile-time link step, so Nix's reference scanner finds zero mentions of the lib in the compiled binary → lib gets dropped from the closure despite being inbuildInputs.The fix is a
preFixuphook that appends--prefix LD_LIBRARY_PATH : ${libayatana-appindicator}/libto thegappsWrapperArgsbash array. Two birds one stone: (a) the Nix string interpolation forces the store path into the output wrapper, so the reference scanner pulls it into the closure, and (b)wrapGAppsHook3then bakes thatLD_LIBRARY_PATHprefix into the runtime wrapper sodlopen()actually finds the lib.This is the canonical pattern for Tauri-on-NixOS tray apps; most Nix packagers hit this exact wall once and then memorize the idiom.
Files changed
Just
flake.nix— 15 additions, 0 deletions.Commit
Notes for non-NixOS maintainers
If you don't run NixOS yourself and want to validate this without installing it, the fastest path is to use
nixon your existing Linux box viacurl -L https://nixos.org/nix/install | sh(unprivileged single-user install), then clone this branch and runnix build .#openfang-cli. Nix will handle all the dependencies in isolation — it won't touch your system package manager.If CI would help, I'm happy to add a simple
.github/workflows/nix-build.ymlthat runsnix build .#openfang-cli && nix build .#openfang-desktopon a NixOS runner to catch future regressions. Happy to do that in a follow-up PR if you're open to it.