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.
This commit is contained in:
2026-09-26 10:44:23 +02:00
parent 591eaed6a3
commit 17222f7120
+15 -21
View File
@@ -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}"
'';
};