1{
2 lib,
3 fetchFromGitea,
4 installShellFiles,
5 libX11,
6 libinput,
7 libxcb,
8 libxkbcommon,
9 pixman,
10 pkg-config,
11 stdenv,
12 testers,
13 nixosTests,
14 wayland,
15 wayland-protocols,
16 wayland-scanner,
17 wlroots,
18 writeText,
19 xcbutilwm,
20 xwayland,
21 # Boolean flags
22 enableXWayland ? true,
23 withCustomConfigH ? (configH != null),
24 # Configurable options
25 configH ?
26 if conf != null then
27 lib.warn ''
28 conf parameter is deprecated;
29 use configH instead
30 '' conf
31 else
32 null,
33 # Deprecated options
34 # Remove them before next version of either Nixpkgs or dwl itself
35 conf ? null,
36}:
37
38# If we set withCustomConfigH, let's not forget configH
39assert withCustomConfigH -> (configH != null);
40stdenv.mkDerivation (finalAttrs: {
41 pname = "dwl";
42 version = "0.7";
43
44 src = fetchFromGitea {
45 domain = "codeberg.org";
46 owner = "dwl";
47 repo = "dwl";
48 rev = "v${finalAttrs.version}";
49 hash = "sha256-7SoCITrbMrlfL4Z4hVyPpjB9RrrjLXHP9C5t1DVXBBA=";
50 };
51
52 nativeBuildInputs = [
53 installShellFiles
54 pkg-config
55 wayland-scanner
56 ];
57
58 buildInputs = [
59 libinput
60 libxcb
61 libxkbcommon
62 pixman
63 wayland
64 wayland-protocols
65 wlroots
66 ]
67 ++ lib.optionals enableXWayland [
68 libX11
69 xcbutilwm
70 xwayland
71 ];
72
73 outputs = [
74 "out"
75 "man"
76 ];
77
78 postPatch =
79 let
80 configFile =
81 if lib.isDerivation configH || builtins.isPath configH then
82 configH
83 else
84 writeText "config.h" configH;
85 in
86 lib.optionalString withCustomConfigH "cp ${configFile} config.h";
87
88 makeFlags = [
89 "PKG_CONFIG=${stdenv.cc.targetPrefix}pkg-config"
90 "WAYLAND_SCANNER=wayland-scanner"
91 "PREFIX=$(out)"
92 "MANDIR=$(man)/share/man"
93 ]
94 ++ lib.optionals enableXWayland [
95 ''XWAYLAND="-DXWAYLAND"''
96 ''XLIBS="xcb xcb-icccm"''
97 ];
98
99 strictDeps = true;
100
101 # required for whitespaces in makeFlags
102 __structuredAttrs = true;
103
104 passthru = {
105 tests = {
106 version = testers.testVersion {
107 package = finalAttrs.finalPackage;
108 # `dwl -v` emits its version string to stderr and returns 1
109 command = "dwl -v 2>&1; return 0";
110 };
111 basic = nixosTests.dwl;
112 };
113 };
114
115 meta = {
116 homepage = "https://codeberg.org/dwl/dwl";
117 changelog = "https://codeberg.org/dwl/dwl/src/branch/${finalAttrs.version}/CHANGELOG.md";
118 description = "Dynamic window manager for Wayland";
119 longDescription = ''
120 dwl is a compact, hackable compositor for Wayland based on wlroots. It is
121 intended to fill the same space in the Wayland world that dwm does in X11,
122 primarily in terms of philosophy, and secondarily in terms of
123 functionality. Like dwm, dwl is:
124
125 - Easy to understand, hack on, and extend with patches
126 - One C source file (or a very small number) configurable via config.h
127 - Tied to as few external dependencies as possible
128 '';
129 license = lib.licenses.gpl3Only;
130 maintainers = [ ];
131 inherit (wayland.meta) platforms;
132 mainProgram = "dwl";
133 };
134})
135# TODO: custom patches from upstream website