From 17222f7120f02f0dab84ccc7bb0f85c397e8d9fd Mon Sep 17 00:00:00 2001 From: puttaalu Date: Sat, 26 Sep 2026 10:44:23 +0200 Subject: [PATCH] Make the desktop flake build on macOS Wayland is Linux-only and refuses to evaluate on darwin, so qtwayland is now added only on Linux (macOS uses the Cocoa QPA plugin in qtbase). The package, dev shell, and plugin search path all build from one platform- guarded module list. Evaluates on aarch64-darwin; Linux is unchanged. --- desktop/flake.nix | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/desktop/flake.nix b/desktop/flake.nix index 7e9b1f3..9d975bd 100644 --- a/desktop/flake.nix +++ b/desktop/flake.nix @@ -10,18 +10,20 @@ flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; + inherit (pkgs) lib stdenv; - qtPlugins = pkgs.lib.makeSearchPathOutput "out" "lib/qt-6/plugins" [ - pkgs.qt6.qtbase - pkgs.qt6.qtwayland - pkgs.qt6.qtimageformats - ]; + # Wayland is Linux-only; macOS uses the Cocoa QPA plugin inside qtbase, + # so qtwayland is added only on Linux (it refuses to evaluate on darwin). + qtModules = [ pkgs.qt6.qtbase pkgs.qt6.qtimageformats ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ pkgs.qt6.qtwayland ]; + + qtPlugins = lib.makeSearchPathOutput "out" "lib/qt-6/plugins" qtModules; in { # Installable build: `nix profile install ./desktop` drops "Photog" into # the application menu with its icon. wrapQtAppsHook wraps the binary so - # it finds the Qt platform (xcb + wayland) and image-format plugins on - # its own, without the dev shell. - packages.default = pkgs.stdenv.mkDerivation { + # it finds the Qt platform (Cocoa on macOS; xcb + wayland on Linux) and + # image-format plugins on its own, without the dev shell. + packages.default = stdenv.mkDerivation { pname = "photog"; version = "0.1.0"; src = ./.; @@ -31,12 +33,7 @@ pkg-config qt6.wrapQtAppsHook ]; - buildInputs = with pkgs; [ - qt6.qtbase - qt6.qtwayland - qt6.qtimageformats - qt6Packages.qtkeychain - ]; + buildInputs = [ pkgs.qt6Packages.qtkeychain ] ++ qtModules; }; devShells.default = pkgs.mkShell { @@ -44,15 +41,12 @@ cmake ninja pkg-config - qt6.qtbase - qt6.qtwayland # native Wayland QPA plugin - qt6.qtimageformats # HEIF/HEIC + others, read by QImage - qt6Packages.qtkeychain # password → libsecret / kwallet - ]; + qt6Packages.qtkeychain # password → Keychain (macOS) / libsecret / kwallet + ] ++ qtModules; shellHook = '' - # Let a binary run straight from the build dir find Qt's platform - # (xcb + wayland) and image-format plugins without wrapQtAppsHook. + # Let a binary run straight from the build dir find Qt's platform and + # image-format plugins without wrapQtAppsHook. export QT_PLUGIN_PATH="${qtPlugins}''${QT_PLUGIN_PATH:+:$QT_PLUGIN_PATH}" ''; };