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, imagemagick,
libXrandr, libXrandr,
libdrm, libdrm,
libelf,
libglvnd, libglvnd,
libpulseaudio, libpulseaudio,
libselinux, libselinux,
@ -24,7 +25,6 @@
nix-update-script, nix-update-script,
ocl-icd, ocl-icd,
opencl-headers, opencl-headers,
pcre,
pcre2, pcre2,
pkg-config, pkg-config,
python3, python3,
@ -40,15 +40,20 @@
zlib, zlib,
# Feature flags # Feature flags
audioSupport ? true, audioSupport ? true,
brightnessSupport ? true,
dbusSupport ? true,
flashfetchSupport ? false, flashfetchSupport ? false,
terminalSupport ? true,
gnomeSupport ? true, gnomeSupport ? true,
imageSupport ? true, imageSupport ? true,
openclSupport ? true, openclSupport ? true,
openglSupport ? true,
rpmSupport ? false, rpmSupport ? false,
sqliteSupport ? true, sqliteSupport ? true,
vulkanSupport ? true, vulkanSupport ? true,
waylandSupport ? true, waylandSupport ? true,
x11Support ? true, x11Support ? true,
xfceSupport ? true,
}: }:
stdenv.mkDerivation (finalAttrs: { stdenv.mkDerivation (finalAttrs: {
pname = "fastfetch"; pname = "fastfetch";
@ -76,88 +81,108 @@ stdenv.mkDerivation (finalAttrs: {
buildInputs = buildInputs =
let let
commonDeps = [ commonDeps = [
pcre
pcre2
yyjson yyjson
]; ];
# Cross-platform optional dependencies # Cross-platform optional dependencies
imageDeps = lib.optionals imageSupport [ imageDeps = lib.optionals imageSupport [
# Image output as ascii art.
chafa chafa
# Images in terminal using sixel or kitty graphics protocol
imagemagick imagemagick
]; ];
sqliteDeps = lib.optionals sqliteSupport [ sqliteDeps = lib.optionals sqliteSupport [
# linux - Needed for pkg & rpm package count.
# darwin - Used for fast wallpaper detection before macOS Sonoma
sqlite sqlite
]; ];
linuxCoreDeps = lib.optionals stdenv.hostPlatform.isLinux [ linuxCoreDeps = lib.optionals stdenv.hostPlatform.isLinux (
[
hwdata hwdata
libselinux ]
libsepol # Fallback if both `wayland` and `x11` are not available. AMD GPU properties detection
util-linux ++ lib.optional (!x11Support && !waylandSupport) libdrm
zlib );
];
linuxFeatureDeps = lib.optionals stdenv.hostPlatform.isLinux ( linuxFeatureDeps = lib.optionals stdenv.hostPlatform.isLinux (
lib.optionals gnomeSupport [ lib.optionals audioSupport [
dbus # Sound device detection
dconf
glib
libsysprof-capture
]
++ lib.optionals audioSupport [
libpulseaudio 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 [ ++ lib.optionals openclSupport [
# OpenCL module
ocl-icd ocl-icd
opencl-headers opencl-headers
] ]
++ lib.optionals vulkanSupport [ ++ lib.optionals openglSupport [
libdrm # OpenGL module
ddcutil libglvnd
] ]
++ lib.optionals rpmSupport [ ++ lib.optionals rpmSupport [
# Slower fallback for rpm package count. Needed on openSUSE.
rpm rpm
] ]
); ++ lib.optionals terminalSupport [
# Needed for st terminal font detection.
waylandDeps = lib.optionals waylandSupport [ libelf
wayland ]
]; ++ lib.optionals vulkanSupport [
# Vulkan module & fallback for GPU output
vulkanDeps = lib.optionals vulkanSupport [
vulkan-loader vulkan-loader
]; ]
++ lib.optionals waylandSupport [
x11Deps = lib.optionals x11Support [ # 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 libXrandr
libglvnd
libxcb libxcb
# Required by libxcb messages
xorg.libXau xorg.libXau
xorg.libXdmcp xorg.libXdmcp
xorg.libXext xorg.libXext
]; ]
++ lib.optionals xfceSupport [
x11XfceDeps = lib.optionals (x11Support && (!stdenv.hostPlatform.isDarwin)) [ # Needed for XFWM theme and XFCE Terminal font.
xfce.xfconf xfce.xfconf
]; ]
);
macosDeps = lib.optionals stdenv.hostPlatform.isDarwin [ macosDeps = lib.optionals stdenv.hostPlatform.isDarwin [
apple-sdk_15 apple-sdk_15
moltenvk moltenvk
]; ];
in in
commonDeps commonDeps ++ imageDeps ++ sqliteDeps ++ linuxCoreDeps ++ linuxFeatureDeps ++ macosDeps;
++ imageDeps
++ sqliteDeps
++ linuxCoreDeps
++ linuxFeatureDeps
++ waylandDeps
++ vulkanDeps
++ x11Deps
++ x11XfceDeps
++ macosDeps;
cmakeFlags = cmakeFlags =
[ [
@ -167,41 +192,49 @@ stdenv.mkDerivation (finalAttrs: {
(lib.cmakeBool "ENABLE_SYSTEM_YYJSON" true) (lib.cmakeBool "ENABLE_SYSTEM_YYJSON" true)
# Feature flags # Feature flags
(lib.cmakeBool "BUILD_FLASHFETCH" flashfetchSupport)
(lib.cmakeBool "ENABLE_IMAGEMAGICK6" false) (lib.cmakeBool "ENABLE_IMAGEMAGICK6" false)
(lib.cmakeBool "ENABLE_IMAGEMAGICK7" imageSupport) (lib.cmakeBool "ENABLE_IMAGEMAGICK7" imageSupport)
(lib.cmakeBool "ENABLE_CHAFA" imageSupport) (lib.cmakeBool "ENABLE_CHAFA" imageSupport)
(lib.cmakeBool "ENABLE_ZLIB" imageSupport)
(lib.cmakeBool "ENABLE_SQLITE3" sqliteSupport) (lib.cmakeBool "ENABLE_SQLITE3" sqliteSupport)
]
++ lib.optionals stdenv.hostPlatform.isLinux [
(lib.cmakeBool "ENABLE_PULSE" audioSupport) (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_GIO" gnomeSupport)
(lib.cmakeBool "ENABLE_DCONF" gnomeSupport) (lib.cmakeBool "ENABLE_DCONF" gnomeSupport)
(lib.cmakeBool "ENABLE_DBUS" gnomeSupport)
(lib.cmakeBool "ENABLE_ZLIB" imageSupport)
(lib.cmakeBool "ENABLE_OPENCL" openclSupport) (lib.cmakeBool "ENABLE_OPENCL" openclSupport)
(lib.cmakeBool "ENABLE_DRM" vulkanSupport) (lib.cmakeBool "ENABLE_EGL" openglSupport)
(lib.cmakeBool "ENABLE_DRM_AMDGPU" vulkanSupport) (lib.cmakeBool "ENABLE_GLX" openglSupport)
(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_RPM" rpmSupport) (lib.cmakeBool "ENABLE_RPM" rpmSupport)
(lib.cmakeBool "BUILD_FLASHFETCH" flashfetchSupport) (lib.cmakeBool "ENABLE_DRM" (!x11Support && !waylandSupport))
] (lib.cmakeBool "ENABLE_DRM_AMDGPU" (!x11Support && !waylandSupport))
++ lib.optionals stdenv.hostPlatform.isLinux [
(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_PCI_IDS_PATH" "${hwdata}/share/hwdata/pci.ids")
(lib.cmakeOptionType "filepath" "CUSTOM_AMDGPU_IDS_PATH" "${libdrm}/share/libdrm/amdgpu.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. Fast and highly customizable system info script.
Feature flags (all default to 'true' except rpmSupport and flashfetchSupport): 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) * rpmSupport: RPM package detection (default: false)
* sqliteSupport: Package counting via SQLite
* terminalSupport: Terminal font detection
* vulkanSupport: Vulkan GPU information and DRM features * vulkanSupport: Vulkan GPU information and DRM features
* waylandSupport: Wayland display detection * waylandSupport: Wayland display detection
* x11Support: X11 display information * x11Support: X11 display information
* flashfetchSupport: Build the flashfetch utility (default: false) * xfceSupport: XFCE integration for theme and terminal font detection
* imageSupport: Image rendering (chafa and imagemagick)
* sqliteSupport: Package counting via SQLite
* audioSupport: PulseAudio functionality
* gnomeSupport: GNOME integration (dconf, dbus, gio)
* openclSupport: OpenCL features
''; '';
}; };
}) })

View File

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