ports/qt5.nix
Qt 5.15 for Fil-C, as an override of the qt5 scope (libsForQt5 is built from final.qt5, so its packages see these modules too). How Fil-C builds see the build platform's Qt is in build-tools.nix. Check with
nix build --impure --expr 'import ./tests/qt5.nix { }'which runs widgets, networking, SQL, XML, SVG, QML/JavaScript, Qt Quick and Quick Controls 2 programs on the offscreen platform and under Xvfb.
qtModule puts the scope's qmake hook in nativeBuildInputs, where splicing picks the build platform's: that hook propagates the native qtbase, and the module's setup hooks then fail with "detected mismatched Qt dependencies". Use this scope's own hook, which adds the Fil-C qtbase (whose qmake and moc are build-platform programs).
Qt modules' build tools (qtdeclarative's qmlcachegen and qmltyperegistrar, native programs in its dev output) are looked up on PATH, where a cross build has only the build platform's Qt.
Needs no other module's tools (and qtdeclarative, a long build, depends on it).
qtbase's setup hook collects mkspecs for QMAKEPATH only from nativeBuildInputs, which in a cross build are the build platform's; a module's Qt dependencies (qtdeclarative for qtquickcontrols2, say) are buildInputs, so qmake did not see them ("Some of the required modules (qtHaveModule(quick)) are not available. Skipped."). Collect them too.
The GTK 3 port has no X11 backend, and Qt's GTK 3 platform theme (native file dialogs and styling) includes <gdk/gdkx.h>.
The xcb platform plugin needs libxkbcommon-x11, which the shared libxkbcommon port leaves out (-Denable-x11=false). Its X11 tests (which need Xvfb) find their cases through __start_/__stop_ section symbols, which do not link under Fil-C, so leave those out.
Qt refuses pkg-config in a cross build without a sysroot, and a sysroot of / turns -L/nix/store/... into -L//nix/store/..., which the compiler wrapper then drops as an impure path.
Every file that includes <QtCore> outside QtCore emits a .qtversion section as module-level assembly, which crashes the Fil-C compiler. The header is installed, so this covers users too.
QtCore's CPU feature probe saves %rbx around CPUID and spells XGETBV as bytes; Fil-C only lowers the canonical forms. RDRAND has no lowering, so leave it to the kernel's generator. Its Valgrind check is a client request (inline assembly), which stops too.
QProcess's forkfd probes waitid(P_PIDFD) and clone(CLONE_PIDFD) through syscall(), which Fil-C refuses by stopping the program.
QMutexLocker, QReadLocker and QWriteLocker keep their lock's address in a quintptr with a "locked" bit, QMap nodes their parent with the colour bit, and QModelIndex its internal pointer. Integer fields lose the capability, so these are pointers now.
QByteArray/QString::fromRawData point their header at the data with an offset from the header, so data() had the header's bounds; raw-data headers keep the data pointer instead.
Fil-C ignores section attributes on data, so plugins have no .qtmetadata section; find the metadata in the whole file.
QThread names threads with prctl(PR_SET_NAME, (unsigned long)name); the integer has no capability, so the runtime's prctl trapped.
QSemaphore wakes with FUTEX_WAKE_OP, which Fil-C's futex refuses.
Nixpkgs configures a cross qtbase with the linux-generic-g++ device spec and CROSS_COMPILE=${targetPrefix}. Fil-C's compiler has no target prefix, and the spec refuses an empty CROSS_COMPILE. Point it at the wrapper's bin directory instead; the wrapper has ar, nm, objcopy and strip there, and cc and c++ rather than gcc and g++. The compiler is Clang, which prints no LIBRARY_PATH for qmake's default-library-path probe; as clang, qmake asks -print-search-dirs.
The bundled Mapbox GL uses Boost 1.65, which needs std::unary_function; libc++ removed it in C++17 unless asked to keep it (Nixpkgs builds Qt with GCC and libstdc++).
GType is a pointer in Fil-C's GLib, and C++ cannot switch on one.
QQuickDeferredPointer keeps an item pointer and two flag bits in a quintptr; the first ComboBox trapped in setIndicator().
QtScript is the 2009 JavaScriptCore: its JIT emits machine code and the module-level assembly of JITStubs.cpp crashes the compiler; its values are NaN-boxed integers and its collector scans the native stack conservatively, which cannot find Fil-C's pointers. Deprecated in Qt 5.5; QJSEngine (qtdeclarative) works.
The V4 engine NaN-boxes heap pointers into quint64 values and passes them around as integers (ReturnedValue), which drops their capabilities; keep them pointer-typed. Also QJSValue, PropertyKey, QFlagPointer/QBiPointer, QQmlNotifierEndpoint and sparse-array nodes, which keep pointers with flag bits in integers.