1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 apple-sdk_15,
6 chafa,
7 cmake,
8 dbus,
9 dconf,
10 ddcutil,
11 glib,
12 hwdata,
13 imagemagick,
14 libXrandr,
15 libdrm,
16 libelf,
17 libglvnd,
18 libpulseaudio,
19 libselinux,
20 libsepol,
21 libsysprof-capture,
22 libxcb,
23 makeBinaryWrapper,
24 moltenvk,
25 nix-update-script,
26 ocl-icd,
27 opencl-headers,
28 pcre2,
29 pkg-config,
30 python3,
31 rpm,
32 sqlite,
33 util-linux,
34 versionCheckHook,
35 vulkan-loader,
36 wayland,
37 xfce,
38 xorg,
39 yyjson,
40 zlib,
41 zfs,
42 # Feature flags
43 audioSupport ? true,
44 brightnessSupport ? true,
45 dbusSupport ? true,
46 flashfetchSupport ? false,
47 terminalSupport ? true,
48 gnomeSupport ? true,
49 imageSupport ? true,
50 openclSupport ? true,
51 openglSupport ? true,
52 rpmSupport ? false,
53 sqliteSupport ? true,
54 vulkanSupport ? true,
55 waylandSupport ? true,
56 x11Support ? true,
57 xfceSupport ? true,
58 zfsSupport ? false,
59}:
60stdenv.mkDerivation (finalAttrs: {
61 pname = "fastfetch";
62 version = "2.49.0";
63
64 src = fetchFromGitHub {
65 owner = "fastfetch-cli";
66 repo = "fastfetch";
67 tag = finalAttrs.version;
68 hash = "sha256-M1/VThHWRB6MbmPpHcgaM3j07kmuj0RnjblKo54RatY=";
69 };
70
71 outputs = [
72 "out"
73 "man"
74 ];
75
76 nativeBuildInputs = [
77 cmake
78 makeBinaryWrapper
79 pkg-config
80 python3
81 ];
82
83 buildInputs =
84 let
85 commonDeps = [
86 yyjson
87 ];
88
89 # Cross-platform optional dependencies
90 imageDeps = lib.optionals imageSupport [
91 # Image output as ascii art.
92 chafa
93 # Images in terminal using sixel or kitty graphics protocol
94 imagemagick
95 ];
96
97 sqliteDeps = lib.optionals sqliteSupport [
98 # linux - Needed for pkg & rpm package count.
99 # darwin - Used for fast wallpaper detection before macOS Sonoma
100 sqlite
101 ];
102
103 linuxCoreDeps = lib.optionals stdenv.hostPlatform.isLinux (
104 [
105 hwdata
106 ]
107 # Fallback if both `wayland` and `x11` are not available. AMD GPU properties detection
108 ++ lib.optional (!x11Support && !waylandSupport) libdrm
109 );
110
111 linuxFeatureDeps = lib.optionals stdenv.hostPlatform.isLinux (
112 lib.optionals audioSupport [
113 # Sound device detection
114 libpulseaudio
115 ]
116 ++ lib.optionals brightnessSupport [
117 # Brightness detection of external displays
118 ddcutil
119 ]
120 ++ lib.optionals dbusSupport [
121 # Bluetooth, wifi, player & media detection
122 dbus
123 ]
124 ++ lib.optionals gnomeSupport [
125 # Needed for values that are only stored in DConf + Fallback for GSettings.
126 dconf
127 glib
128 # Required by glib messages
129 libsysprof-capture
130 pcre2
131 # Required by gio messages
132 libselinux
133 util-linux
134 # Required by selinux
135 libsepol
136 ]
137 ++ lib.optionals imageSupport [
138 # Faster image output when using kitty graphics protocol.
139 zlib
140 ]
141 ++ lib.optionals openclSupport [
142 # OpenCL module
143 ocl-icd
144 opencl-headers
145 ]
146 ++ lib.optionals openglSupport [
147 # OpenGL module
148 libglvnd
149 ]
150 ++ lib.optionals rpmSupport [
151 # Slower fallback for rpm package count. Needed on openSUSE.
152 rpm
153 ]
154 ++ lib.optionals terminalSupport [
155 # Needed for st terminal font detection.
156 libelf
157 ]
158 ++ lib.optionals vulkanSupport [
159 # Vulkan module & fallback for GPU output
160 vulkan-loader
161 ]
162 ++ lib.optionals waylandSupport [
163 # Better display performance and output in wayland sessions. Supports different refresh rates per monitor.
164 wayland
165 ]
166 ++ lib.optionals x11Support [
167 # At least one of them sould be present in X11 sessions for better display detection and faster WM detection.
168 # The *randr ones provide multi monitor support The libxcb* ones usually have better performance.
169 libXrandr
170 libxcb
171 # Required by libxcb messages
172 xorg.libXau
173 xorg.libXdmcp
174 xorg.libXext
175 ]
176 ++ lib.optionals xfceSupport [
177 # Needed for XFWM theme and XFCE Terminal font.
178 xfce.xfconf
179 ]
180 ++ lib.optionals zfsSupport [
181 # Needed for zpool module
182 zfs
183 ]
184 );
185
186 macosDeps = lib.optionals stdenv.hostPlatform.isDarwin [
187 apple-sdk_15
188 moltenvk
189 ];
190 in
191 commonDeps ++ imageDeps ++ sqliteDeps ++ linuxCoreDeps ++ linuxFeatureDeps ++ macosDeps;
192
193 cmakeFlags = [
194 (lib.cmakeOptionType "filepath" "CMAKE_INSTALL_SYSCONFDIR" "${placeholder "out"}/etc")
195 (lib.cmakeBool "ENABLE_DIRECTX_HEADERS" false)
196 (lib.cmakeBool "ENABLE_SYSTEM_YYJSON" true)
197
198 # Feature flags
199 (lib.cmakeBool "BUILD_FLASHFETCH" flashfetchSupport)
200
201 (lib.cmakeBool "ENABLE_IMAGEMAGICK6" false)
202 (lib.cmakeBool "ENABLE_IMAGEMAGICK7" imageSupport)
203 (lib.cmakeBool "ENABLE_CHAFA" imageSupport)
204
205 (lib.cmakeBool "ENABLE_SQLITE3" sqliteSupport)
206
207 (lib.cmakeBool "ENABLE_LIBZFS" zfsSupport)
208 ]
209 ++ lib.optionals stdenv.hostPlatform.isLinux [
210 (lib.cmakeBool "ENABLE_PULSE" audioSupport)
211
212 (lib.cmakeBool "ENABLE_DDCUTIL" brightnessSupport)
213
214 (lib.cmakeBool "ENABLE_DBUS" dbusSupport)
215
216 (lib.cmakeBool "ENABLE_ELF" terminalSupport)
217
218 (lib.cmakeBool "ENABLE_GIO" gnomeSupport)
219 (lib.cmakeBool "ENABLE_DCONF" gnomeSupport)
220
221 (lib.cmakeBool "ENABLE_ZLIB" imageSupport)
222
223 (lib.cmakeBool "ENABLE_OPENCL" openclSupport)
224
225 (lib.cmakeBool "ENABLE_EGL" openglSupport)
226 (lib.cmakeBool "ENABLE_GLX" openglSupport)
227
228 (lib.cmakeBool "ENABLE_RPM" rpmSupport)
229
230 (lib.cmakeBool "ENABLE_DRM" (!x11Support && !waylandSupport))
231 (lib.cmakeBool "ENABLE_DRM_AMDGPU" (!x11Support && !waylandSupport))
232
233 (lib.cmakeBool "ENABLE_VULKAN" vulkanSupport)
234
235 (lib.cmakeBool "ENABLE_WAYLAND" waylandSupport)
236
237 (lib.cmakeBool "ENABLE_XCB_RANDR" x11Support)
238 (lib.cmakeBool "ENABLE_XRANDR" x11Support)
239
240 (lib.cmakeBool "ENABLE_XFCONF" xfceSupport)
241
242 (lib.cmakeOptionType "filepath" "CUSTOM_PCI_IDS_PATH" "${hwdata}/share/hwdata/pci.ids")
243 (lib.cmakeOptionType "filepath" "CUSTOM_AMDGPU_IDS_PATH" "${libdrm}/share/libdrm/amdgpu.ids")
244 ];
245
246 postPatch = ''
247 substituteInPlace completions/fastfetch.{bash,fish,zsh} --replace-fail python3 '${python3.interpreter}'
248 '';
249
250 postInstall = ''
251 wrapProgram $out/bin/fastfetch \
252 --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath finalAttrs.buildInputs}"
253 ''
254 + lib.optionalString flashfetchSupport ''
255 wrapProgram $out/bin/flashfetch \
256 --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath finalAttrs.buildInputs}"
257 '';
258
259 nativeInstallCheckInputs = [ versionCheckHook ];
260 versionCheckProgramArg = "--version";
261 doInstallCheck = true;
262
263 passthru.updateScript = nix-update-script { };
264
265 meta = {
266 description = "Actively maintained, feature-rich and performance oriented, neofetch like system information tool";
267 homepage = "https://github.com/fastfetch-cli/fastfetch";
268 changelog = "https://github.com/fastfetch-cli/fastfetch/releases/tag/${finalAttrs.version}";
269 license = lib.licenses.mit;
270 maintainers = with lib.maintainers; [
271 luftmensch-luftmensch
272 khaneliman
273 ];
274 platforms = lib.platforms.all;
275 mainProgram = "fastfetch";
276 longDescription = ''
277 Fast and highly customizable system info script.
278
279 Feature flags (all default to 'true' except rpmSupport, flashfetchSupport and zfsSupport):
280 * audioSupport: PulseAudio functionality
281 * brightnessSupport: External display brightness detection via DDCUtil
282 * dbusSupport: DBus functionality for Bluetooth, WiFi, player & media detection
283 * flashfetchSupport: Build the flashfetch utility (default: false)
284 * gnomeSupport: GNOME integration (dconf, dbus, gio)
285 * imageSupport: Image rendering (chafa and imagemagick)
286 * openclSupport: OpenCL features
287 * openglSupport: OpenGL features
288 * rpmSupport: RPM package detection (default: false)
289 * sqliteSupport: Package counting via SQLite
290 * terminalSupport: Terminal font detection
291 * vulkanSupport: Vulkan GPU information and DRM features
292 * waylandSupport: Wayland display detection
293 * x11Support: X11 display information
294 * xfceSupport: XFCE integration for theme and terminal font detection
295 * zfsSupport: zpool information
296 '';
297 };
298})