From 5e550e18a931e4692a95c396f03c356065aff8d9 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 16 Dec 2025 16:07:01 -0500 Subject: [PATCH] nix: make Qt6 work on wayland Taking many tips from our `default.nix` (thanks @nt!) this seems to be the minimal overlay required for a flake to get up and running with `piker chart` B) Notes, - for now, we're pinning to a major `cpython` version (3.13) - ensure we (can) build with `nixpkgs.qt6.qtwayland` - add the minimal Qt ld-lib-path linkings including those for plugin use (required for wayland mode). - for now, hardcode "wayland" platform-mode and the linux standard "xdg-shell" integration. - leave some TODOs to better parameterize around py versions. --- flake.nix | 61 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/flake.nix b/flake.nix index 9d4dac29..0fdb3264 100644 --- a/flake.nix +++ b/flake.nix @@ -19,26 +19,71 @@ system: let pkgs = nixpkgs.legacyPackages.${system}; + + # do store-path extractions + qt6baseStorePath = lib.getLib pkgs.qt6.qtbase; + # ?TODO? can remove below since manual linking not needed? + # qt6QtWaylandStorePath = lib.getLib pkgs.qt6.qtwayland; + + # XXX NOTE XXX, for now we overlay specific pkgs via + # a major-version-pinned-`cpython` + cpython = "python313"; + pypkgs = pkgs."${cpython}Packages"; in { default = pkgs.mkShell { - packages = [ - pkgs.python313 - pkgs.uv + + packages = with pkgs; [ + qt6.qtwayland + qt6.qtbase + + uv + python313 # ?TODO^ how to set from `cpython` above? + pypkgs.pyqt6 + pypkgs.pyqt6-sip + pypkgs.qtpy + pypkgs.qdarkstyle + pypkgs.rapidfuzz ]; shellHook = '' - unset PYTHONPATH + # unmask to debug **this** dev-shell-hook + # set -e - # expose C++ stdlib to overlay - export LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib:$LD_LIBRARY_PATH" + # set qt-base/plugin path(s) + QTBASE_PATH="${qt6baseStorePath}/lib" + QT_PLUGIN_PATH="${qt6baseStorePath}/lib/qt-6/plugins" + QT_QPA_PLATFORM_PLUGIN_PATH="$QT_PLUGIN_PATH/platforms" - # always use the ./py313/ venv-subdir + # link in Qt cc lib paths from + LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$QTBASE_PATH" + LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$QT_PLUGIN_PATH" + LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$QT_QPA_PLATFORM_PLUGIN_PATH" + + # link-in c++ stdlib for various AOT-ext-pkgs (numpy, etc.) + LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib:$LD_LIBRARY_PATH" + + export LD_LIBRARY_PATH + + # RUNTIME-SETTINGS + # + # ------ Qt ------ + # XXX, unmask to debug qt .so linking/loading deats + # export QT_DEBUG_PLUGINS=1 + # + # ALSO, for *modern linux* DEs, + # - maybe set wayland-mode (TODO, parametrtize this!) + # * a chosen wayland-mode shell-integration + export QT_QPA_PLATFORM="wayland" + export QT_WAYLAND_SHELL_INTEGRATION="xdg-shell" + + # ------ uv ------ + # - always use the ./py313/ venv-subdir export UV_PROJECT_ENVIRONMENT="py313" - # sync project-env with all extras uv sync --dev --all-extras + # ------ TIPS ------ # NOTE, to launch the py-venv installed `xonsh` (like @goodboy) # run the `nix develop` cmd with, # >> nix develop -c uv run xonsh