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