From 5c1905f549c16292074e739a6a3fc07c1215beb0 Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Sat, 9 Sep 2023 21:55:23 +0300 Subject: [PATCH] hyprland-share-picker: build with meson Nix: combine xdph and the picker into one package --- flake.nix | 3 +-- hyprland-share-picker/meson.build | 21 +++++++++++++++++++ meson.build | 2 +- nix/default.nix | 20 +++++++++++++++--- nix/hyprland-share-picker.nix | 35 ------------------------------- nix/overlays.nix | 10 ++------- 6 files changed, 42 insertions(+), 49 deletions(-) create mode 100644 hyprland-share-picker/meson.build delete mode 100644 nix/hyprland-share-picker.nix diff --git a/flake.nix b/flake.nix index d8baf14..3336652 100644 --- a/flake.nix +++ b/flake.nix @@ -28,7 +28,6 @@ overlays = [ inputs.hyprland-protocols.overlays.default self.overlays.xdg-desktop-portal-hyprland - self.overlays.hyprland-share-picker self.overlays.package-overrides ]; }); @@ -36,7 +35,7 @@ overlays = import ./nix/overlays.nix {inherit self inputs lib;}; packages = eachSystem (system: { - inherit (pkgsFor.${system}) xdg-desktop-portal-hyprland hyprland-share-picker; + inherit (pkgsFor.${system}) xdg-desktop-portal-hyprland; default = self.packages.${system}.xdg-desktop-portal-hyprland; }); diff --git a/hyprland-share-picker/meson.build b/hyprland-share-picker/meson.build new file mode 100644 index 0000000..c984951 --- /dev/null +++ b/hyprland-share-picker/meson.build @@ -0,0 +1,21 @@ +# select either qt6 or qt5 +qtdep = dependency('qt6', 'qt5', modules: ['Widgets']) +qtver = qtdep.version() +qt = import('qt' + qtver[0]) + +ui_files = qt.compile_ui(sources: 'mainpicker.ui') +moc = qt.compile_moc(headers: 'mainpicker.h') + +sources = files([ + 'main.cpp', + 'mainpicker.cpp', + 'mainpicker.h', +]) + +executable('hyprland-share-picker', + sources, + ui_files, + moc, + dependencies: qtdep, + install: true +) diff --git a/meson.build b/meson.build index 0324a4f..77c1a80 100644 --- a/meson.build +++ b/meson.build @@ -41,7 +41,6 @@ if systemd.found() systemd_service_file = 'xdg-desktop-portal-hyprland.service' user_unit_dir = systemd.get_variable(pkgconfig: 'systemduserunitdir', pkgconfig_define: ['prefix', get_option('prefix')]) - conf_data.set('systemd_service', 'SystemdService=' + systemd_service_file) configure_file( configuration: conf_data, @@ -67,3 +66,4 @@ inc = include_directories('.', 'protocols') subdir('protocols') subdir('src') +subdir('hyprland-share-picker') diff --git a/nix/default.nix b/nix/default.nix index aac003c..73fb674 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -5,7 +5,6 @@ meson, ninja, pkg-config, - hyprland-share-picker, libdrm, mesa, pipewire, @@ -13,7 +12,11 @@ systemd, wayland-protocols, wayland-scanner, - grim, + qtbase, + qttools, + qtwayland, + wrapQtAppsHook, + hyprland, slurp, hyprland-protocols, wayland, @@ -31,6 +34,7 @@ stdenv.mkDerivation { pkg-config wayland-scanner makeWrapper + wrapQtAppsHook ]; buildInputs = [ @@ -38,14 +42,24 @@ stdenv.mkDerivation { libdrm mesa pipewire + qtbase + qttools + qtwayland sdbus-cpp systemd wayland wayland-protocols ]; + dontWrapQtApps = true; + postInstall = '' - wrapProgram $out/libexec/xdg-desktop-portal-hyprland --prefix PATH ":" ${lib.makeBinPath [hyprland-share-picker grim slurp]} + wrapProgramShell $out/bin/hyprland-share-picker \ + "''${qtWrapperArgs[@]}" \ + --prefix PATH ":" ${lib.makeBinPath [slurp hyprland]} + + wrapProgramShell $out/libexec/xdg-desktop-portal-hyprland \ + --prefix PATH ":" ${lib.makeBinPath [(placeholder "out")]} ''; meta = with lib; { diff --git a/nix/hyprland-share-picker.nix b/nix/hyprland-share-picker.nix deleted file mode 100644 index 73167b1..0000000 --- a/nix/hyprland-share-picker.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ - stdenv, - lib, - cmake, - qtbase, - qtwayland, - makeShellWrapper, - wrapQtAppsHook, - hyprland, - slurp, - version ? "git", -}: -stdenv.mkDerivation { - pname = "hyprland-share-picker"; - inherit version; - src = ../hyprland-share-picker; - - nativeBuildInputs = [ - cmake - wrapQtAppsHook - makeShellWrapper - ]; - buildInputs = [ - qtbase - qtwayland - ]; - - dontWrapQtApps = true; - - postInstall = '' - wrapProgramShell $out/bin/hyprland-share-picker \ - "''${qtWrapperArgs[@]}" \ - --prefix PATH ":" ${lib.makeBinPath [slurp hyprland]} - ''; -} diff --git a/nix/overlays.nix b/nix/overlays.nix index de3f5b5..854141e 100644 --- a/nix/overlays.nix +++ b/nix/overlays.nix @@ -18,19 +18,13 @@ in { default = mkJoinedOverlays (with self.overlays; [ xdg-desktop-portal-hyprland - hyprland-share-picker package-overrides ]); xdg-desktop-portal-hyprland = final: prev: { xdg-desktop-portal-hyprland = final.callPackage ./default.nix { stdenv = prev.gcc13Stdenv; - inherit (final) hyprland-protocols hyprland-share-picker; - inherit version; - }; - }; - hyprland-share-picker = final: prev: { - hyprland-share-picker = final.callPackage ./hyprland-share-picker.nix { - inherit (final.qt6) qtbase wrapQtAppsHook qtwayland; + inherit (final) hyprland-protocols; + inherit (final.qt6) qtbase qttools wrapQtAppsHook qtwayland; inherit version; }; };