nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 bash,
5 fetchFromGitHub,
6 SDL2,
7 alsa-lib,
8 catch2_3,
9 fftw,
10 glib,
11 gobject-introspection,
12 gpsd,
13 gtk-layer-shell,
14 gtkmm3,
15 iniparser,
16 jsoncpp,
17 libdbusmenu-gtk3,
18 libevdev,
19 libinotify-kqueue,
20 libinput,
21 libjack2,
22 libmpdclient,
23 libnl,
24 libpulseaudio,
25 libsigcxx,
26 libxkbcommon,
27 meson,
28 ncurses,
29 ninja,
30 pipewire,
31 pkg-config,
32 playerctl,
33 portaudio,
34 python3,
35 scdoc,
36 sndio,
37 spdlog,
38 systemdMinimal,
39 udev,
40 upower,
41 versionCheckHook,
42 wayland,
43 wayland-scanner,
44 wireplumber,
45 wrapGAppsHook3,
46
47 cavaSupport ? true,
48 enableManpages ? stdenv.buildPlatform.canExecute stdenv.hostPlatform,
49 evdevSupport ? true,
50 experimentalPatches ? true,
51 gpsSupport ? true,
52 inputSupport ? true,
53 jackSupport ? true,
54 mpdSupport ? true,
55 mprisSupport ? stdenv.hostPlatform.isLinux,
56 niriSupport ? true,
57 nlSupport ? true,
58 pipewireSupport ? true,
59 pulseSupport ? true,
60 rfkillSupport ? true,
61 runTests ? stdenv.buildPlatform.canExecute stdenv.hostPlatform,
62 sndioSupport ? true,
63 systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemdMinimal,
64 traySupport ? true,
65 udevSupport ? true,
66 upowerSupport ? true,
67 wireplumberSupport ? true,
68 withMediaPlayer ? mprisSupport && false,
69 nix-update-script,
70}:
71
72stdenv.mkDerivation (finalAttrs: {
73 pname = "waybar";
74 version = "0.14.0";
75
76 src = fetchFromGitHub {
77 owner = "Alexays";
78 repo = "Waybar";
79 tag = finalAttrs.version;
80 hash = "sha256-mGiBZjfvtZZkSHrha4UF2l1Ogbij8J//r2h4gcZAJ6w=";
81 };
82
83 libcavaSrc = fetchFromGitHub {
84 owner = "LukashonakV";
85 repo = "cava";
86 tag = "0.10.4";
87 hash = "sha256-9eTDqM+O1tA/3bEfd1apm8LbEcR9CVgELTIspSVPMKM=";
88 };
89
90 postUnpack = lib.optional cavaSupport ''
91 pushd "$sourceRoot"
92 cp -R --no-preserve=mode,ownership ${finalAttrs.libcavaSrc} subprojects/cava-0.10.4
93 patchShebangs .
94 popd
95 '';
96
97 nativeBuildInputs = [
98 meson
99 ninja
100 pkg-config
101 wayland-scanner
102 wrapGAppsHook3
103 ]
104 ++ lib.optional withMediaPlayer gobject-introspection
105 ++ lib.optional enableManpages scdoc;
106
107 propagatedBuildInputs = lib.optionals withMediaPlayer [
108 glib
109 playerctl
110 python3.pkgs.pygobject3
111 ];
112
113 buildInputs = [
114 gtk-layer-shell
115 gtkmm3
116 jsoncpp
117 libsigcxx
118 libxkbcommon
119 spdlog
120 wayland
121 ]
122 ++ lib.optionals cavaSupport [
123 SDL2
124 alsa-lib
125 fftw
126 iniparser
127 ncurses
128 portaudio
129 ]
130 ++ lib.optional evdevSupport libevdev
131 ++ lib.optional gpsSupport gpsd
132 ++ lib.optional inputSupport libinput
133 ++ lib.optional jackSupport libjack2
134 ++ lib.optional mpdSupport libmpdclient
135 ++ lib.optional mprisSupport playerctl
136 ++ lib.optional nlSupport libnl
137 ++ lib.optional pulseSupport libpulseaudio
138 ++ lib.optional sndioSupport sndio
139 ++ lib.optional systemdSupport systemdMinimal
140 ++ lib.optional traySupport libdbusmenu-gtk3
141 ++ lib.optional udevSupport udev
142 ++ lib.optional upowerSupport upower
143 ++ lib.optional wireplumberSupport wireplumber
144 ++ lib.optional (cavaSupport || pipewireSupport) pipewire
145 ++ lib.optional (!stdenv.hostPlatform.isLinux) libinotify-kqueue;
146
147 nativeCheckInputs = [ catch2_3 ];
148 doCheck = runTests;
149
150 mesonFlags =
151 (lib.mapAttrsToList lib.mesonEnable {
152 "cava" = cavaSupport && lib.asserts.assertMsg sndioSupport "Sndio support is required for Cava";
153 "dbusmenu-gtk" = traySupport;
154 "gps" = gpsSupport;
155 "jack" = jackSupport;
156 "libevdev" = evdevSupport;
157 "libinput" = inputSupport;
158 "libnl" = nlSupport;
159 "libudev" = udevSupport;
160 "man-pages" = enableManpages;
161 "mpd" = mpdSupport;
162 "mpris" = mprisSupport;
163 "pipewire" = pipewireSupport;
164 "pulseaudio" = pulseSupport;
165 "rfkill" = rfkillSupport;
166 "sndio" = sndioSupport;
167 "systemd" = systemdSupport;
168 "tests" = runTests;
169 "upower_glib" = upowerSupport;
170 "wireplumber" = wireplumberSupport;
171 })
172 ++ (lib.mapAttrsToList lib.mesonBool {
173 "experimental" = experimentalPatches;
174 "niri" = niriSupport;
175 });
176
177 env = lib.optionalAttrs systemdSupport {
178 PKG_CONFIG_SYSTEMD_SYSTEMDUSERUNITDIR = "${placeholder "out"}/lib/systemd/user";
179 };
180
181 postPatch = ''
182 substituteInPlace include/util/command.hpp \
183 --replace-fail /bin/sh ${lib.getExe' bash "sh"}
184 '';
185
186 preFixup = lib.optionalString withMediaPlayer ''
187 cp $src/resources/custom_modules/mediaplayer.py $out/bin/waybar-mediaplayer.py
188
189 wrapProgram $out/bin/waybar-mediaplayer.py \
190 --prefix PYTHONPATH : "$PYTHONPATH:$out/${python3.sitePackages}"
191 '';
192
193 nativeInstallCheckInputs = [
194 versionCheckHook
195 ];
196
197 doInstallCheck = true;
198
199 passthru = {
200 updateScript = nix-update-script { };
201 };
202
203 meta = {
204 homepage = "https://github.com/alexays/waybar";
205 description = "Highly customizable Wayland bar for Sway and Wlroots based compositors";
206 changelog = "https://github.com/alexays/waybar/releases/tag/${finalAttrs.version}";
207 license = lib.licenses.mit;
208 mainProgram = "waybar";
209 maintainers = with lib.maintainers; [
210 FlorianFranzen
211 lovesegfault
212 minijackson
213 rodrgz
214 synthetica
215 khaneliman
216 ];
217 platforms = lib.platforms.linux;
218 };
219})