nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, fetchFromGitLab
4, meson
5, ninja
6, pkg-config
7, wayland-scanner
8, libGL
9, wayland
10, wayland-protocols
11, libinput
12, libxkbcommon
13, pixman
14, libcap
15, mesa
16, xorg
17, libpng
18, ffmpeg_4
19, hwdata
20, seatd
21, vulkan-loader
22, glslang
23, nixosTests
24
25, enableXWayland ? true
26, xwayland ? null
27}:
28
29let
30 generic = { version, hash, extraBuildInputs ? [ ], extraNativeBuildInputs ? [ ], extraPatch ? "" }:
31 stdenv.mkDerivation rec {
32 pname = "wlroots";
33 inherit version;
34
35 src = fetchFromGitLab {
36 domain = "gitlab.freedesktop.org";
37 owner = "wlroots";
38 repo = "wlroots";
39 rev = version;
40 inherit hash;
41 };
42
43 postPatch = extraPatch;
44
45 # $out for the library and $examples for the example programs (in examples):
46 outputs = [ "out" "examples" ];
47
48 strictDeps = true;
49 depsBuildBuild = [ pkg-config ];
50
51 nativeBuildInputs = [ meson ninja pkg-config wayland-scanner ]
52 ++ extraNativeBuildInputs;
53
54 buildInputs = [
55 ffmpeg_4
56 libGL
57 libcap
58 libinput
59 libpng
60 libxkbcommon
61 mesa
62 pixman
63 seatd
64 vulkan-loader
65 wayland
66 wayland-protocols
67 xorg.libX11
68 xorg.xcbutilerrors
69 xorg.xcbutilimage
70 xorg.xcbutilrenderutil
71 xorg.xcbutilwm
72 ]
73 ++ lib.optional enableXWayland xwayland
74 ++ extraBuildInputs;
75
76 mesonFlags =
77 lib.optional (!enableXWayland) "-Dxwayland=disabled"
78 ;
79
80 postFixup = ''
81 # Install ALL example programs to $examples:
82 # screencopy dmabuf-capture input-inhibitor layer-shell idle-inhibit idle
83 # screenshot output-layout multi-pointer rotation tablet touch pointer
84 # simple
85 mkdir -p $examples/bin
86 cd ./examples
87 for binary in $(find . -executable -type f -printf '%P\n' | grep -vE '\.so'); do
88 cp "$binary" "$examples/bin/wlroots-$binary"
89 done
90 '';
91
92 # Test via TinyWL (the "minimum viable product" Wayland compositor based on wlroots):
93 passthru.tests.tinywl = nixosTests.tinywl;
94
95 meta = with lib; {
96 description = "A modular Wayland compositor library";
97 longDescription = ''
98 Pluggable, composable, unopinionated modules for building a Wayland
99 compositor; or about 50,000 lines of code you were going to write anyway.
100 '';
101 inherit (src.meta) homepage;
102 changelog = "https://gitlab.freedesktop.org/wlroots/wlroots/-/tags/${version}";
103 license = licenses.mit;
104 platforms = platforms.linux;
105 maintainers = with maintainers; [ primeos synthetica ];
106 };
107 };
108
109in
110rec {
111 wlroots_0_14 = generic {
112 version = "0.14.1";
113 hash = "sha256-wauk7TCL/V7fxjOZY77KiPbfydIc9gmOiYFOuum4UOs=";
114 };
115
116 wlroots_0_15 = generic {
117 version = "0.15.1";
118 hash = "sha256-MFR38UuB/wW7J9ODDUOfgTzKLse0SSMIRYTpEaEdRwM=";
119 extraBuildInputs = [ vulkan-loader ];
120 extraNativeBuildInputs = [ glslang ];
121 };
122
123 wlroots_0_16 = generic {
124 version = "0.16.2";
125 hash = "sha256-JeDDYinio14BOl6CbzAPnJDOnrk4vgGNMN++rcy2ItQ=";
126 extraBuildInputs = [ vulkan-loader ];
127 extraNativeBuildInputs = [ glslang ];
128 extraPatch = ''
129 substituteInPlace backend/drm/meson.build \
130 --replace /usr/share/hwdata/ ${hwdata}/share/hwdata/
131 '';
132 };
133
134 wlroots = wlroots_0_15;
135}