{ lib, rustPlatform, pkg-config, qt6, writeShellScript, runCommand, }: let # nixpkgs splits Qt tools across packages: moc/rcc/qtpaths live in qtbase, # qmltyperegistrar and qmlcachegen live in qtdeclarative. qt-build-utils # finds tools via `qmake -query QT_INSTALL_LIBEXECS`, which only returns # qtbase paths, so those two tools are invisible. Fix: combine them into a # single symlink tree and point a qmake wrapper at it. qtBuildTools = runCommand "qt6-build-tools" { } '' mkdir -p $out/libexec $out/bin for f in ${qt6.qtbase}/libexec/* ${qt6.qtbase}/bin/*; do ln -sf "$f" "$out/$(echo "$f" | grep -o 'libexec\|bin')/$(basename "$f")" done for tool in qmltyperegistrar qmlcachegen; do src="${qt6.qtdeclarative}/libexec/$tool" [ -f "$src" ] && ln -sf "$src" "$out/libexec/$tool" done ''; qmakeWrapper = writeShellScript "qmake6" '' if [ "$1" = "-query" ]; then case "$2" in QT_HOST_LIBEXECS|QT_HOST_LIBEXECS/get|QT_INSTALL_LIBEXECS|QT_INSTALL_LIBEXECS/get) echo "${qtBuildTools}/libexec"; exit 0;; QT_HOST_BINS|QT_HOST_BINS/get|QT_INSTALL_BINS|QT_INSTALL_BINS/get) echo "${qtBuildTools}/bin"; exit 0;; esac fi exec ${qt6.qtbase}/bin/qmake6 "$@" ''; in rustPlatform.buildRustPackage { pname = "nova-plugin"; version = "0.1.0"; src = lib.cleanSource ../plugin; cargoLock.lockFile = ../plugin/Cargo.lock; nativeBuildInputs = [ pkg-config qt6.qtbase qt6.qtdeclarative ]; buildInputs = [ qt6.qtbase qt6.qtdeclarative ]; dontWrapQtApps = true; # qt6.qtbase's setup hook overrides QMAKE after derivation attrs are set, # so re-assert it in preBuild which runs after all setup hooks. preBuild = '' export QMAKE=${qmakeWrapper} ''; installPhase = '' runHook preInstall qml_dir="$out/lib/qt-6/qml/NovaStats" mkdir -p "$qml_dir" install -m755 target/*/release/libnova_plugin.so "$qml_dir/libNovaStats.so" install -m644 target/*/cxxqt/qml_modules/NovaStats/qmldir "$qml_dir/" install -m644 target/*/cxxqt/qml_modules/NovaStats/plugin.qmltypes "$qml_dir/" 2>/dev/null || true runHook postInstall ''; meta = { description = "In-process system stats QML plugin for nova-shell"; platforms = lib.platforms.linux; }; }