mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-23 14:55:57 +01:00
Nix & Meson: init for v2-rewrite
This commit is contained in:
parent
c9347d8e9b
commit
505975aa05
10 changed files with 213 additions and 113 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -55,6 +55,7 @@ dkms.conf
|
|||
build/
|
||||
build-*/
|
||||
|
||||
.cache
|
||||
.vscode/
|
||||
|
||||
hyprland-share-picker/build/
|
||||
|
|
|
@ -25,11 +25,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1683014792,
|
||||
"narHash": "sha256-6Va9iVtmmsw4raBc3QKvQT2KT/NGRWlvUlJj46zN8B8=",
|
||||
"lastModified": 1693844670,
|
||||
"narHash": "sha256-t69F2nBB8DNQUWHD809oJZJVE+23XBrth4QZuVd6IE0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "1a411f23ba299db155a5b45d5e145b85a7aafc42",
|
||||
"rev": "3c15feef7770eb5500a4b8792623e2d6f598c9c1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
inputs.hyprland-protocols.overlays.default
|
||||
self.overlays.xdg-desktop-portal-hyprland
|
||||
self.overlays.hyprland-share-picker
|
||||
self.overlays.package-overrides
|
||||
];
|
||||
});
|
||||
in {
|
||||
|
|
137
meson.build
137
meson.build
|
@ -1,111 +1,38 @@
|
|||
project(
|
||||
'xdg-desktop-portal-hyprland',
|
||||
'c',
|
||||
version: '0.5.0',
|
||||
project('xdg-desktop-portal-hyprland', 'cpp', 'c',
|
||||
version: '2.0.0',
|
||||
license: 'MIT',
|
||||
meson_version: '>=0.58.0',
|
||||
default_options: ['c_std=c11', 'warning_level=2', 'werror=false'],
|
||||
)
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
|
||||
add_project_arguments(cc.get_supported_arguments([
|
||||
'-Wno-missing-braces',
|
||||
'-Wno-missing-field-initializers',
|
||||
'-Wno-unused-parameter',
|
||||
'-D_POSIX_C_SOURCE=200809L',
|
||||
'-D_GNU_SOURCE',
|
||||
]), language: 'c')
|
||||
|
||||
prefix = get_option('prefix')
|
||||
sysconfdir = get_option('sysconfdir')
|
||||
add_project_arguments('-DSYSCONFDIR="@0@"'.format(join_paths(prefix, sysconfdir)), language : 'c')
|
||||
|
||||
inc = include_directories('include')
|
||||
|
||||
rt = cc.find_library('rt')
|
||||
pipewire = dependency('libpipewire-0.3', version: '>= 0.3.62')
|
||||
hyprland_protos = dependency('hyprland-protocols', version: '>=0.2', fallback: 'hyprland-protocols')
|
||||
wayland_client = dependency('wayland-client')
|
||||
wayland_protos = dependency('wayland-protocols', version: '>=1.24')
|
||||
iniparser = dependency('inih')
|
||||
gbm = dependency('gbm')
|
||||
drm = dependency('libdrm')
|
||||
uuid = dependency('uuid')
|
||||
|
||||
epoll = dependency('', required: false)
|
||||
if (not cc.has_function('timerfd_create', prefix: '#include <sys/timerfd.h>') or
|
||||
not cc.has_function('signalfd', prefix: '#include <sys/signalfd.h>'))
|
||||
epoll = dependency('epoll-shim')
|
||||
endif
|
||||
|
||||
if get_option('sd-bus-provider') == 'auto'
|
||||
assert(get_option('auto_features').auto(), 'sd-bus-provider must not be set to auto since auto_features != auto')
|
||||
sdbus = dependency('libsystemd',
|
||||
required: false,
|
||||
not_found_message: 'libsystemd not found, trying libelogind',
|
||||
)
|
||||
if not sdbus.found()
|
||||
sdbus = dependency('libelogind',
|
||||
required: false,
|
||||
not_found_message: 'libelogind not found, trying basu',
|
||||
)
|
||||
endif
|
||||
if not sdbus.found()
|
||||
sdbus = dependency('basu',
|
||||
required: false,
|
||||
)
|
||||
endif
|
||||
if not sdbus.found()
|
||||
error('Neither libsystemd, nor libelogind, nor basu was found')
|
||||
endif
|
||||
else
|
||||
sdbus = dependency(get_option('sd-bus-provider'))
|
||||
endif
|
||||
add_project_arguments('-DHAVE_' + sdbus.name().to_upper() + '=1', language: 'c')
|
||||
|
||||
subdir('protocols')
|
||||
|
||||
xdpw_files = files([
|
||||
'src/core/main.c',
|
||||
'src/core/logger.c',
|
||||
'src/core/config.c',
|
||||
'src/core/request.c',
|
||||
'src/core/session.c',
|
||||
'src/core/timer.c',
|
||||
'src/core/timespec_util.c',
|
||||
'src/core/utils.c',
|
||||
'src/screenshot/screenshot.c',
|
||||
'src/screencast/screencast.c',
|
||||
'src/screencast/screencast_common.c',
|
||||
'src/screencast/wlr_screencast.c',
|
||||
'src/screencast/pipewire_screencast.c',
|
||||
'src/screencast/fps_limit.c',
|
||||
'src/globalshortcuts/global_shortcuts.c'
|
||||
])
|
||||
|
||||
executable(
|
||||
'xdg-desktop-portal-hyprland',
|
||||
[xdpw_files, wl_proto_files],
|
||||
dependencies: [
|
||||
wayland_client,
|
||||
sdbus,
|
||||
pipewire,
|
||||
rt,
|
||||
iniparser,
|
||||
gbm,
|
||||
drm,
|
||||
epoll,
|
||||
uuid,
|
||||
meson_version: '>=0.63.0',
|
||||
default_options: [
|
||||
'warning_level=2',
|
||||
'optimization=3',
|
||||
'buildtype=release',
|
||||
'debug=false',
|
||||
# 'cpp_std=c++23' # not yet supported by meson, as of version 0.63.0
|
||||
],
|
||||
include_directories: [inc],
|
||||
install: true,
|
||||
install_dir: get_option('libexecdir'),
|
||||
)
|
||||
|
||||
# clang v14.0.6 uses C++2b instead of C++23, so we've gotta account for that
|
||||
# replace the following with a project default option once meson gets support for C++23
|
||||
cpp_compiler = meson.get_compiler('cpp')
|
||||
if cpp_compiler.has_argument('-std=c++23')
|
||||
add_global_arguments('-std=c++23', language: 'cpp')
|
||||
elif cpp_compiler.has_argument('-std=c++2b')
|
||||
add_global_arguments('-std=c++2b', language: 'cpp')
|
||||
else
|
||||
error('Could not configure current C++ compiler (' + cpp_compiler.get_id() + ' ' + cpp_compiler.version() + ') with required C++ standard (C++23)')
|
||||
endif
|
||||
|
||||
add_project_arguments(cpp_compiler.get_supported_arguments([
|
||||
'-Wno-missing-field-initializers',
|
||||
'-Wno-narrowing',
|
||||
'-Wno-pointer-arith',
|
||||
'-Wno-unused-parameter',
|
||||
'-Wno-unused-value',
|
||||
'-fpermissive'
|
||||
]), language: 'cpp')
|
||||
|
||||
conf_data = configuration_data()
|
||||
conf_data.set('libexecdir',
|
||||
join_paths(get_option('prefix'), get_option('libexecdir')))
|
||||
conf_data.set('libexecdir', join_paths(get_option('prefix'), get_option('libexecdir')))
|
||||
conf_data.set('systemd_service', '')
|
||||
|
||||
systemd = dependency('systemd', required: get_option('systemd'))
|
||||
|
@ -136,3 +63,7 @@ install_data(
|
|||
install_dir: join_paths(get_option('datadir'), 'xdg-desktop-portal', 'portals'),
|
||||
)
|
||||
|
||||
inc = include_directories('.', 'protocols')
|
||||
|
||||
subdir('protocols')
|
||||
subdir('src')
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
option('sd-bus-provider', type: 'combo', choices: ['auto', 'libsystemd', 'libelogind', 'basu'], value: 'auto', description: 'Provider of the sd-bus library')
|
||||
option('systemd', type: 'feature', value: 'auto', description: 'Install systemd user service unit')
|
||||
|
|
64
nix/default.nix
Normal file
64
nix/default.nix
Normal file
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
lib,
|
||||
stdenv,
|
||||
makeWrapper,
|
||||
meson,
|
||||
ninja,
|
||||
pkg-config,
|
||||
cairo,
|
||||
hyprland-share-picker,
|
||||
libdrm,
|
||||
libjpeg,
|
||||
mesa,
|
||||
pango,
|
||||
pipewire,
|
||||
sdbus-cpp,
|
||||
systemd,
|
||||
wayland-protocols,
|
||||
wayland-scanner,
|
||||
grim,
|
||||
slurp,
|
||||
hyprland-protocols,
|
||||
wayland,
|
||||
version ? "git",
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
pname = "xdg-desktop-portal-hyprland";
|
||||
inherit version;
|
||||
|
||||
src = ../.;
|
||||
|
||||
nativeBuildInputs = [
|
||||
meson
|
||||
ninja
|
||||
pkg-config
|
||||
wayland-scanner
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
cairo
|
||||
hyprland-protocols
|
||||
libdrm
|
||||
libjpeg
|
||||
mesa
|
||||
pango
|
||||
pipewire
|
||||
sdbus-cpp
|
||||
systemd
|
||||
wayland
|
||||
wayland-protocols
|
||||
];
|
||||
|
||||
postInstall = ''
|
||||
wrapProgram $out/libexec/xdg-desktop-portal-hyprland --prefix PATH ":" ${lib.makeBinPath [hyprland-share-picker grim slurp]}
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/hyprwm/xdg-desktop-portal-hyprland";
|
||||
description = "xdg-desktop-portal backend for Hyprland";
|
||||
maintainers = with maintainers; [fufexan];
|
||||
platforms = platforms.linux;
|
||||
license = licenses.mit;
|
||||
};
|
||||
}
|
34
nix/hyprland-share-picker.nix
Normal file
34
nix/hyprland-share-picker.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
stdenv,
|
||||
lib,
|
||||
cmake,
|
||||
qtbase,
|
||||
makeShellWrapper,
|
||||
wrapQtAppsHook,
|
||||
hyprland,
|
||||
slurp,
|
||||
version ? "git",
|
||||
...
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
pname = "hyprland-share-picker";
|
||||
inherit version;
|
||||
src = ../hyprland-share-picker;
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
wrapQtAppsHook
|
||||
makeShellWrapper
|
||||
];
|
||||
buildInputs = [
|
||||
qtbase
|
||||
];
|
||||
|
||||
dontWrapQtApps = true;
|
||||
|
||||
postInstall = ''
|
||||
wrapProgramShell $out/bin/hyprland-share-picker \
|
||||
"''${qtWrapperArgs[@]}" \
|
||||
--prefix PATH ":" ${lib.makeBinPath [slurp hyprland]}
|
||||
'';
|
||||
}
|
41
nix/overlays.nix
Normal file
41
nix/overlays.nix
Normal file
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
self,
|
||||
inputs,
|
||||
lib,
|
||||
}: let
|
||||
mkJoinedOverlays = overlays: final: prev:
|
||||
lib.foldl' (attrs: overlay: attrs // (overlay final prev)) {} overlays;
|
||||
mkDate = longDate: (lib.concatStringsSep "-" [
|
||||
(builtins.substring 0 4 longDate)
|
||||
(builtins.substring 4 2 longDate)
|
||||
(builtins.substring 6 2 longDate)
|
||||
]);
|
||||
version = "0.pre" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
|
||||
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.libsForQt5.callPackage ./hyprland-share-picker.nix {inherit version;};
|
||||
};
|
||||
package-overrides = final: prev: {
|
||||
sdbus-cpp = prev.sdbus-cpp.overrideAttrs (self: super: {
|
||||
version = "1.3.0";
|
||||
src = prev.fetchFromGitHub {
|
||||
repo = "sdbus-cpp";
|
||||
owner = "Kistler-Group";
|
||||
rev = "v${self.version}";
|
||||
hash = "sha256-S/8/I2wmWukpP+RGPxKbuO44wIExzeYZL49IO+KOqg4=";
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
|
@ -1,3 +1,13 @@
|
|||
wayland_protos = dependency('wayland-protocols',
|
||||
version: '>=1.31',
|
||||
default_options: ['tests=false'],
|
||||
)
|
||||
|
||||
hyprland_protos = dependency('hyprland-protocols',
|
||||
version: '>=0.2',
|
||||
fallback: 'hyprland-protocols',
|
||||
)
|
||||
|
||||
wl_protocol_dir = wayland_protos.get_variable('pkgdatadir')
|
||||
hl_protocol_dir = hyprland_protos.get_variable('pkgdatadir')
|
||||
|
||||
|
@ -10,14 +20,12 @@ if wayland_scanner_dep.found()
|
|||
else
|
||||
wayland_scanner = find_program('wayland-scanner', native: true)
|
||||
endif
|
||||
|
||||
client_protocols = [
|
||||
wl_protocol_dir / 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml',
|
||||
wl_protocol_dir / 'unstable/xdg-output/xdg-output-unstable-v1.xml',
|
||||
hl_protocol_dir / 'protocols/hyprland-toplevel-export-v1.xml',
|
||||
hl_protocol_dir / 'protocols/hyprland-global-shortcuts-v1.xml',
|
||||
'wlr-screencopy-unstable-v1.xml',
|
||||
'wlr-foreign-toplevel-management-unstable-v1.xml',
|
||||
hl_protocol_dir / 'protocols/hyprland-toplevel-export-v1.xml',
|
||||
hl_protocol_dir / 'protocols/hyprland-global-shortcuts-v1.xml',
|
||||
wl_protocol_dir / 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml',
|
||||
]
|
||||
|
||||
wl_proto_files = []
|
||||
|
@ -33,7 +41,7 @@ foreach xml: client_protocols
|
|||
client_header = custom_target(
|
||||
xml.underscorify() + '_client_h',
|
||||
input: xml,
|
||||
output: '@BASENAME@-client-protocol.h',
|
||||
output: '@BASENAME@-protocol.h',
|
||||
command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'],
|
||||
)
|
||||
|
||||
|
|
21
src/meson.build
Normal file
21
src/meson.build
Normal file
|
@ -0,0 +1,21 @@
|
|||
globber = run_command('find', '.', '-name', '*.cpp', check: true)
|
||||
src = globber.stdout().strip().split('\n')
|
||||
|
||||
executable('xdg-desktop-portal-hyprland',
|
||||
[src, wl_proto_files],
|
||||
dependencies: [
|
||||
dependency('cairo'),
|
||||
dependency('gbm'),
|
||||
dependency('libdrm'),
|
||||
dependency('libjpeg'),
|
||||
dependency('libpipewire-0.3'),
|
||||
dependency('pango'),
|
||||
dependency('pangocairo'),
|
||||
dependency('sdbus-c++'),
|
||||
dependency('threads'),
|
||||
dependency('wayland-client'),
|
||||
],
|
||||
include_directories: inc,
|
||||
install: true,
|
||||
install_dir: get_option('libexecdir')
|
||||
)
|
Loading…
Reference in a new issue