fastfetch: refactor dependencies more

Remove some unneeded dependencies and group better.
This commit is contained in:
Austin Horstman 2025-05-02 13:21:43 -05:00
parent 26a0b9dbd8
commit 2c1a3811e4
No known key found for this signature in database
2 changed files with 120 additions and 77 deletions

View File

@ -13,6 +13,7 @@
imagemagick,
libXrandr,
libdrm,
libelf,
libglvnd,
libpulseaudio,
libselinux,
@ -24,7 +25,6 @@
nix-update-script,
ocl-icd,
opencl-headers,
pcre,
pcre2,
pkg-config,
python3,
@ -40,15 +40,20 @@
zlib,
# Feature flags
audioSupport ? true,
brightnessSupport ? true,
dbusSupport ? true,
flashfetchSupport ? false,
terminalSupport ? true,
gnomeSupport ? true,
imageSupport ? true,
openclSupport ? true,
openglSupport ? true,
rpmSupport ? false,
sqliteSupport ? true,
vulkanSupport ? true,
waylandSupport ? true,
x11Support ? true,
xfceSupport ? true,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "fastfetch";
@ -76,88 +81,108 @@ stdenv.mkDerivation (finalAttrs: {
buildInputs =
let
commonDeps = [
pcre
pcre2
yyjson
];
# Cross-platform optional dependencies
imageDeps = lib.optionals imageSupport [
# Image output as ascii art.
chafa
# Images in terminal using sixel or kitty graphics protocol
imagemagick
];
sqliteDeps = lib.optionals sqliteSupport [
# linux - Needed for pkg & rpm package count.
# darwin - Used for fast wallpaper detection before macOS Sonoma
sqlite
];
linuxCoreDeps = lib.optionals stdenv.hostPlatform.isLinux [
hwdata
libselinux
libsepol
util-linux
zlib
];
linuxCoreDeps = lib.optionals stdenv.hostPlatform.isLinux (
[
hwdata
]
# Fallback if both `wayland` and `x11` are not available. AMD GPU properties detection
++ lib.optional (!x11Support && !waylandSupport) libdrm
);
linuxFeatureDeps = lib.optionals stdenv.hostPlatform.isLinux (
lib.optionals gnomeSupport [
dbus
dconf
glib
libsysprof-capture
]
++ lib.optionals audioSupport [
lib.optionals audioSupport [
# Sound device detection
libpulseaudio
]
++ lib.optionals brightnessSupport [
# Brightness detection of external displays
ddcutil
]
++ lib.optionals dbusSupport [
# Bluetooth, wifi, player & media detection
dbus
]
++ lib.optionals gnomeSupport [
# Needed for values that are only stored in DConf + Fallback for GSettings.
dconf
glib
# Required by glib messages
libsysprof-capture
pcre2
# Required by gio messages
libselinux
util-linux
# Required by selinux
libsepol
]
++ lib.optionals imageSupport [
# Faster image output when using kitty graphics protocol.
zlib
]
++ lib.optionals openclSupport [
# OpenCL module
ocl-icd
opencl-headers
]
++ lib.optionals vulkanSupport [
libdrm
ddcutil
++ lib.optionals openglSupport [
# OpenGL module
libglvnd
]
++ lib.optionals rpmSupport [
# Slower fallback for rpm package count. Needed on openSUSE.
rpm
]
++ lib.optionals terminalSupport [
# Needed for st terminal font detection.
libelf
]
++ lib.optionals vulkanSupport [
# Vulkan module & fallback for GPU output
vulkan-loader
]
++ lib.optionals waylandSupport [
# Better display performance and output in wayland sessions. Supports different refresh rates per monitor.
wayland
]
++ lib.optionals x11Support [
# At least one of them sould be present in X11 sessions for better display detection and faster WM detection.
# The *randr ones provide multi monitor support The libxcb* ones usually have better performance.
libXrandr
libxcb
# Required by libxcb messages
xorg.libXau
xorg.libXdmcp
xorg.libXext
]
++ lib.optionals xfceSupport [
# Needed for XFWM theme and XFCE Terminal font.
xfce.xfconf
]
);
waylandDeps = lib.optionals waylandSupport [
wayland
];
vulkanDeps = lib.optionals vulkanSupport [
vulkan-loader
];
x11Deps = lib.optionals x11Support [
libXrandr
libglvnd
libxcb
xorg.libXau
xorg.libXdmcp
xorg.libXext
];
x11XfceDeps = lib.optionals (x11Support && (!stdenv.hostPlatform.isDarwin)) [
xfce.xfconf
];
macosDeps = lib.optionals stdenv.hostPlatform.isDarwin [
apple-sdk_15
moltenvk
];
in
commonDeps
++ imageDeps
++ sqliteDeps
++ linuxCoreDeps
++ linuxFeatureDeps
++ waylandDeps
++ vulkanDeps
++ x11Deps
++ x11XfceDeps
++ macosDeps;
commonDeps ++ imageDeps ++ sqliteDeps ++ linuxCoreDeps ++ linuxFeatureDeps ++ macosDeps;
cmakeFlags =
[
@ -167,41 +192,49 @@ stdenv.mkDerivation (finalAttrs: {
(lib.cmakeBool "ENABLE_SYSTEM_YYJSON" true)
# Feature flags
(lib.cmakeBool "BUILD_FLASHFETCH" flashfetchSupport)
(lib.cmakeBool "ENABLE_IMAGEMAGICK6" false)
(lib.cmakeBool "ENABLE_IMAGEMAGICK7" imageSupport)
(lib.cmakeBool "ENABLE_CHAFA" imageSupport)
(lib.cmakeBool "ENABLE_ZLIB" imageSupport)
(lib.cmakeBool "ENABLE_SQLITE3" sqliteSupport)
]
++ lib.optionals stdenv.hostPlatform.isLinux [
(lib.cmakeBool "ENABLE_PULSE" audioSupport)
(lib.cmakeBool "ENABLE_DDCUTIL" brightnessSupport)
(lib.cmakeBool "ENABLE_DBUS" dbusSupport)
(lib.cmakeBool "ENABLE_ELF" terminalSupport)
(lib.cmakeBool "ENABLE_GIO" gnomeSupport)
(lib.cmakeBool "ENABLE_DCONF" gnomeSupport)
(lib.cmakeBool "ENABLE_DBUS" gnomeSupport)
(lib.cmakeBool "ENABLE_ZLIB" imageSupport)
(lib.cmakeBool "ENABLE_OPENCL" openclSupport)
(lib.cmakeBool "ENABLE_DRM" vulkanSupport)
(lib.cmakeBool "ENABLE_DRM_AMDGPU" vulkanSupport)
(lib.cmakeBool "ENABLE_VULKAN" vulkanSupport)
(lib.cmakeBool "ENABLE_DDCUTIL" vulkanSupport)
(lib.cmakeBool "ENABLE_EGL" vulkanSupport)
(lib.cmakeBool "ENABLE_WAYLAND" waylandSupport)
(lib.cmakeBool "ENABLE_GLX" x11Support)
(lib.cmakeBool "ENABLE_X11" x11Support)
(lib.cmakeBool "ENABLE_XCB" x11Support)
(lib.cmakeBool "ENABLE_XCB_RANDR" x11Support)
(lib.cmakeBool "ENABLE_XFCONF" (x11Support && (!stdenv.hostPlatform.isDarwin)))
(lib.cmakeBool "ENABLE_XRANDR" x11Support)
(lib.cmakeBool "ENABLE_EGL" openglSupport)
(lib.cmakeBool "ENABLE_GLX" openglSupport)
(lib.cmakeBool "ENABLE_RPM" rpmSupport)
(lib.cmakeBool "BUILD_FLASHFETCH" flashfetchSupport)
]
++ lib.optionals stdenv.hostPlatform.isLinux [
(lib.cmakeBool "ENABLE_DRM" (!x11Support && !waylandSupport))
(lib.cmakeBool "ENABLE_DRM_AMDGPU" (!x11Support && !waylandSupport))
(lib.cmakeBool "ENABLE_VULKAN" vulkanSupport)
(lib.cmakeBool "ENABLE_WAYLAND" waylandSupport)
(lib.cmakeBool "ENABLE_X11" x11Support)
(lib.cmakeBool "ENABLE_XCB" x11Support)
(lib.cmakeBool "ENABLE_XCB_RANDR" x11Support)
(lib.cmakeBool "ENABLE_XRANDR" x11Support)
(lib.cmakeBool "ENABLE_XFCONF" xfceSupport)
(lib.cmakeOptionType "filepath" "CUSTOM_PCI_IDS_PATH" "${hwdata}/share/hwdata/pci.ids")
(lib.cmakeOptionType "filepath" "CUSTOM_AMDGPU_IDS_PATH" "${libdrm}/share/libdrm/amdgpu.ids")
];
@ -241,16 +274,21 @@ stdenv.mkDerivation (finalAttrs: {
Fast and highly customizable system info script.
Feature flags (all default to 'true' except rpmSupport and flashfetchSupport):
* audioSupport: PulseAudio functionality
* brightnessSupport: External display brightness detection via DDCUtil
* dbusSupport: DBus functionality for Bluetooth, WiFi, player & media detection
* flashfetchSupport: Build the flashfetch utility (default: false)
* gnomeSupport: GNOME integration (dconf, dbus, gio)
* imageSupport: Image rendering (chafa and imagemagick)
* openclSupport: OpenCL features
* openglSupport: OpenGL features
* rpmSupport: RPM package detection (default: false)
* sqliteSupport: Package counting via SQLite
* terminalSupport: Terminal font detection
* vulkanSupport: Vulkan GPU information and DRM features
* waylandSupport: Wayland display detection
* x11Support: X11 display information
* flashfetchSupport: Build the flashfetch utility (default: false)
* imageSupport: Image rendering (chafa and imagemagick)
* sqliteSupport: Package counting via SQLite
* audioSupport: PulseAudio functionality
* gnomeSupport: GNOME integration (dconf, dbus, gio)
* openclSupport: OpenCL features
* xfceSupport: XFCE integration for theme and terminal font detection
'';
};
})

View File

@ -1,13 +1,18 @@
{ fastfetch }:
fastfetch.override {
audioSupport = false;
brightnessSupport = false;
dbusSupport = false;
flashfetchSupport = false;
gnomeSupport = false;
imageSupport = false;
openclSupport = false;
openglSupport = false;
rpmSupport = false;
sqliteSupport = false;
terminalSupport = false;
vulkanSupport = false;
waylandSupport = false;
x11Support = false;
xfceSupport = false;
}