···1+{ stdenv
2+, lib
3+, fetchFromGitHub
4+, pkg-config
5+, libxcb
6+, libxkbcommon
7+, wayland
8+, wayland-protocols
9+, wlroots
10+, enable-xwayland ? true, xwayland, libX11
11+, patches ? [ ]
12+, conf ? null
13+, writeText
14+}:
15+16+stdenv.mkDerivation rec {
17+ pname = "dwl";
18+ version = "0.1";
19+20+ src = fetchFromGitHub {
21+ owner = "djpohly";
22+ repo = pname;
23+ rev = "v${version}";
24+ sha256 = "QoKaeF5DbSX0xciwc/0VKpubn/001cJjoZ+UzVDX4qE=";
25+ };
26+27+ nativeBuildInputs = [ pkg-config ];
28+ buildInputs = [
29+ libxcb
30+ libxkbcommon
31+ wayland
32+ wayland-protocols
33+ wlroots
34+ ] ++ lib.optionals enable-xwayland [ xwayland libX11 ];
35+36+ # Allow users to set their own list of patches
37+ inherit patches;
38+39+ prePatch = lib.optionalString enable-xwayland ''
40+ sed -i -e '$ s|^#||' config.mk
41+ '';
42+43+ # Allow users to set an alternative config.def.h
44+ postPatch = let
45+ configFile = if lib.isDerivation conf || builtins.isPath conf
46+ then conf
47+ else writeText "config.def.h" conf;
48+ in lib.optionalString (conf != null) "cp ${configFile} config.def.h";
49+50+ dontConfigure = true;
51+52+ installPhase = ''
53+ runHook preInstall
54+ install -d $out/bin
55+ install -m755 dwl $out/bin
56+ runHook postInstall
57+ '';
58+59+ meta = with lib; {
60+ homepage = "https://github.com/djpohly/dwl/";
61+ description = "Dynamic window manager for Wayland";
62+ longDescription = ''
63+ dwl is a compact, hackable compositor for Wayland based on wlroots. It is
64+ intended to fill the same space in the Wayland world that dwm does in X11,
65+ primarily in terms of philosophy, and secondarily in terms of
66+ functionality. Like dwm, dwl is:
67+68+ - Easy to understand, hack on, and extend with patches
69+ - One C source file (or a very small number) configurable via config.h
70+ - Limited to 2000 SLOC to promote hackability
71+ - Tied to as few external dependencies as possible
72+ '';
73+ license = licenses.gpl3Only;
74+ maintainers = with maintainers; [ AndersonTorres ];
75+ platforms = with platforms; linux;
76+ };
77+}
78+# TODO: custom patches from upstream website
79+# TODO: investigate the modifications in the upstream unstable version