1{
2 fetchFromGitHub,
3 lib,
4 stdenv,
5 pkg-config,
6 makeWrapper,
7 meson,
8 ninja,
9 installShellFiles,
10 libxcb,
11 xcbutilkeysyms,
12 xcbutil,
13 xcbutilwm,
14 xcbutilxrm,
15 libstartup_notification,
16 libX11,
17 pcre2,
18 libev,
19 yajl,
20 xcb-util-cursor,
21 perl,
22 pango,
23 perlPackages,
24 libxkbcommon,
25 xorgserver,
26 xvfb-run,
27 xdotool,
28 xorg,
29 which,
30 asciidoc,
31 xmlto,
32 docbook_xml_dtd_45,
33 docbook_xsl,
34 findXMLCatalogs,
35 nixosTests,
36 nix-update-script,
37}:
38
39stdenv.mkDerivation (finalAttrs: {
40 pname = "i3";
41 version = "4.24";
42
43 src = fetchFromGitHub {
44 owner = "i3";
45 repo = "i3";
46 tag = finalAttrs.version;
47 hash = "sha256-2tuhfB/SMN+osCBfZtw/yDPhNNEhBH4Qo6dexpqVWYk=";
48 };
49
50 nativeBuildInputs = [
51 pkg-config
52 makeWrapper
53 meson
54 ninja
55 installShellFiles
56 perl
57 asciidoc
58 xmlto
59 docbook_xml_dtd_45
60 docbook_xsl
61 findXMLCatalogs
62 ];
63
64 mesonFlags = [
65 (lib.mesonBool "docs" true)
66 (lib.mesonBool "mans" true)
67 ];
68
69 buildInputs = [
70 libxcb
71 xcbutilkeysyms
72 xcbutil
73 xcbutilwm
74 xcbutilxrm
75 libxkbcommon
76 libstartup_notification
77 libX11
78 pcre2
79 libev
80 yajl
81 xcb-util-cursor
82 perl
83 pango
84 perlPackages.AnyEventI3
85 perlPackages.X11XCB
86 perlPackages.IPCRun
87 perlPackages.ExtUtilsPkgConfig
88 perlPackages.InlineC
89 ];
90
91 postPatch = ''
92 patchShebangs .
93
94 # This testcase generates a Perl executable file with a shebang, and
95 # patchShebangs can't replace a shebang in the middle of a file.
96 if [ -f testcases/t/318-i3-dmenu-desktop.t ]; then
97 substituteInPlace testcases/t/318-i3-dmenu-desktop.t \
98 --replace-fail "#!/usr/bin/env perl" "#!${lib.getExe perl}"
99 fi
100 '';
101
102 # xvfb-run is available only on Linux
103 doCheck = stdenv.hostPlatform.isLinux;
104
105 nativeCheckInputs = lib.optionals finalAttrs.finalPackage.doCheck [
106 xorgserver
107 xvfb-run
108 xdotool
109 xorg.setxkbmap
110 xorg.xrandr
111 which
112 ];
113
114 checkPhase = ''
115 runHook preCheck
116
117 test_failed=
118 # "| cat" disables fancy progress reporting which makes the log unreadable.
119 ./complete-run.pl -p 1 --keep-xserver-output | cat || test_failed="complete-run.pl returned $?"
120 if [ -z "$test_failed" ]; then
121 # Apparently some old versions of `complete-run.pl` did not return a
122 # proper exit code, so check the log for signs of errors too.
123 grep -q '^not ok' latest/complete-run.log && test_failed="test log contains errors" ||:
124 fi
125 if [ -n "$test_failed" ]; then
126 echo "***** Error: $test_failed"
127 echo "===== Test log ====="
128 cat latest/complete-run.log
129 echo "===== End of test log ====="
130 false
131 fi
132
133 runHook postCheck
134 '';
135
136 postInstall = ''
137 wrapProgram "$out/bin/i3-save-tree" --prefix PERL5LIB ":" "$PERL5LIB"
138 for program in $out/bin/i3-sensible-*; do
139 sed -i 's/which/command -v/' $program
140 done
141
142 installManPage man/*.1
143 '';
144
145 separateDebugInfo = true;
146
147 passthru = {
148 updateScript = nix-update-script { };
149 tests = {
150 inherit (nixosTests) i3wm;
151 };
152 };
153
154 meta = {
155 description = "Tiling window manager";
156 homepage = "https://i3wm.org";
157 maintainers = with lib.maintainers; [
158 modulistic
159 fpletz
160 ];
161 mainProgram = "i3";
162 license = lib.licenses.bsd3;
163 platforms = lib.platforms.unix;
164
165 longDescription = ''
166 A tiling window manager primarily targeted at advanced users and
167 developers. Based on a tree as data structure, supports tiling,
168 stacking, and tabbing layouts, handled dynamically, as well as
169 floating windows. Configured via plain text file. Multi-monitor.
170 UTF-8 clean.
171 '';
172 };
173})