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:
+15
-21
@@ -10,18 +10,20 @@
|
|||||||
flake-utils.lib.eachDefaultSystem (system:
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = import nixpkgs { inherit system; };
|
||||||
|
inherit (pkgs) lib stdenv;
|
||||||
|
|
||||||
qtPlugins = pkgs.lib.makeSearchPathOutput "out" "lib/qt-6/plugins" [
|
# Wayland is Linux-only; macOS uses the Cocoa QPA plugin inside qtbase,
|
||||||
pkgs.qt6.qtbase
|
# so qtwayland is added only on Linux (it refuses to evaluate on darwin).
|
||||||
pkgs.qt6.qtwayland
|
qtModules = [ pkgs.qt6.qtbase pkgs.qt6.qtimageformats ]
|
||||||
pkgs.qt6.qtimageformats
|
++ lib.optionals stdenv.hostPlatform.isLinux [ pkgs.qt6.qtwayland ];
|
||||||
];
|
|
||||||
|
qtPlugins = lib.makeSearchPathOutput "out" "lib/qt-6/plugins" qtModules;
|
||||||
in {
|
in {
|
||||||
# Installable build: `nix profile install ./desktop` drops "Photog" into
|
# Installable build: `nix profile install ./desktop` drops "Photog" into
|
||||||
# the application menu with its icon. wrapQtAppsHook wraps the binary so
|
# the application menu with its icon. wrapQtAppsHook wraps the binary so
|
||||||
# it finds the Qt platform (xcb + wayland) and image-format plugins on
|
# it finds the Qt platform (Cocoa on macOS; xcb + wayland on Linux) and
|
||||||
# its own, without the dev shell.
|
# image-format plugins on its own, without the dev shell.
|
||||||
packages.default = pkgs.stdenv.mkDerivation {
|
packages.default = stdenv.mkDerivation {
|
||||||
pname = "photog";
|
pname = "photog";
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
@@ -31,12 +33,7 @@
|
|||||||
pkg-config
|
pkg-config
|
||||||
qt6.wrapQtAppsHook
|
qt6.wrapQtAppsHook
|
||||||
];
|
];
|
||||||
buildInputs = with pkgs; [
|
buildInputs = [ pkgs.qt6Packages.qtkeychain ] ++ qtModules;
|
||||||
qt6.qtbase
|
|
||||||
qt6.qtwayland
|
|
||||||
qt6.qtimageformats
|
|
||||||
qt6Packages.qtkeychain
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
@@ -44,15 +41,12 @@
|
|||||||
cmake
|
cmake
|
||||||
ninja
|
ninja
|
||||||
pkg-config
|
pkg-config
|
||||||
qt6.qtbase
|
qt6Packages.qtkeychain # password → Keychain (macOS) / libsecret / kwallet
|
||||||
qt6.qtwayland # native Wayland QPA plugin
|
] ++ qtModules;
|
||||||
qt6.qtimageformats # HEIF/HEIC + others, read by QImage
|
|
||||||
qt6Packages.qtkeychain # password → libsecret / kwallet
|
|
||||||
];
|
|
||||||
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
# Let a binary run straight from the build dir find Qt's platform
|
# Let a binary run straight from the build dir find Qt's platform and
|
||||||
# (xcb + wayland) and image-format plugins without wrapQtAppsHook.
|
# image-format plugins without wrapQtAppsHook.
|
||||||
export QT_PLUGIN_PATH="${qtPlugins}''${QT_PLUGIN_PATH:+:$QT_PLUGIN_PATH}"
|
export QT_PLUGIN_PATH="${qtPlugins}''${QT_PLUGIN_PATH:+:$QT_PLUGIN_PATH}"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user