···11+{ stdenv
22+, lib
33+, fetchFromGitHub
44+, pkg-config
55+, libxcb
66+, libxkbcommon
77+, wayland
88+, wayland-protocols
99+, wlroots
1010+, enable-xwayland ? true, xwayland, libX11
1111+, patches ? [ ]
1212+, conf ? null
1313+, writeText
1414+}:
1515+1616+stdenv.mkDerivation rec {
1717+ pname = "dwl";
1818+ version = "0.1";
1919+2020+ src = fetchFromGitHub {
2121+ owner = "djpohly";
2222+ repo = pname;
2323+ rev = "v${version}";
2424+ sha256 = "QoKaeF5DbSX0xciwc/0VKpubn/001cJjoZ+UzVDX4qE=";
2525+ };
2626+2727+ nativeBuildInputs = [ pkg-config ];
2828+ buildInputs = [
2929+ libxcb
3030+ libxkbcommon
3131+ wayland
3232+ wayland-protocols
3333+ wlroots
3434+ ] ++ lib.optionals enable-xwayland [ xwayland libX11 ];
3535+3636+ # Allow users to set their own list of patches
3737+ inherit patches;
3838+3939+ prePatch = lib.optionalString enable-xwayland ''
4040+ sed -i -e '$ s|^#||' config.mk
4141+ '';
4242+4343+ # Allow users to set an alternative config.def.h
4444+ postPatch = let
4545+ configFile = if lib.isDerivation conf || builtins.isPath conf
4646+ then conf
4747+ else writeText "config.def.h" conf;
4848+ in lib.optionalString (conf != null) "cp ${configFile} config.def.h";
4949+5050+ dontConfigure = true;
5151+5252+ installPhase = ''
5353+ runHook preInstall
5454+ install -d $out/bin
5555+ install -m755 dwl $out/bin
5656+ runHook postInstall
5757+ '';
5858+5959+ meta = with lib; {
6060+ homepage = "https://github.com/djpohly/dwl/";
6161+ description = "Dynamic window manager for Wayland";
6262+ longDescription = ''
6363+ dwl is a compact, hackable compositor for Wayland based on wlroots. It is
6464+ intended to fill the same space in the Wayland world that dwm does in X11,
6565+ primarily in terms of philosophy, and secondarily in terms of
6666+ functionality. Like dwm, dwl is:
6767+6868+ - Easy to understand, hack on, and extend with patches
6969+ - One C source file (or a very small number) configurable via config.h
7070+ - Limited to 2000 SLOC to promote hackability
7171+ - Tied to as few external dependencies as possible
7272+ '';
7373+ license = licenses.gpl3Only;
7474+ maintainers = with maintainers; [ AndersonTorres ];
7575+ platforms = with platforms; linux;
7676+ };
7777+}
7878+# TODO: custom patches from upstream website
7979+# TODO: investigate the modifications in the upstream unstable version