mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
NixOS support
This commit is contained in:
@@ -44,7 +44,7 @@ Title, Separator, OS, Host, Kernel, Uptime, Processes, Packages, Shell, Resoluti
|
||||
|
||||
##### Logos
|
||||
```
|
||||
Android, Arch, Arco, Artix, CachyOS, CentOS, Debian, Endeavour, Fedora, Garuda, Gentoo, KDE Neon, Linux, Manjaro, Mint, OpenSUSE, OpenSUSE Tumbleweed, OpenSUSE LEAP, Pop!_OS, RebornOS, Ubuntu, Void, Zorin
|
||||
Android, Arch, Arco, Artix, CachyOS, CentOS, Debian, Endeavour, Fedora, Garuda, Gentoo, KDE Neon, Linux, Manjaro, Mint, NixOS, OpenSUSE, OpenSUSE Tumbleweed, OpenSUSE LEAP, Pop!_OS, RebornOS, Ubuntu, Void, Zorin
|
||||
```
|
||||
* Most of the logos have a small variant. Access it by appending _small to the logo name.
|
||||
* Some logos have an old variant. Access it by appending _old to the logo name.
|
||||
@@ -53,7 +53,7 @@ Android, Arch, Arco, Artix, CachyOS, CentOS, Debian, Endeavour, Fedora, Garuda,
|
||||
|
||||
##### Package managers
|
||||
```
|
||||
Pacman, dpkg, rpm, emerge, xbps, Flatpak, Snap
|
||||
Pacman, dpkg, rpm, emerge, xbps, nix, Flatpak, Snap
|
||||
```
|
||||
|
||||
##### WM themes
|
||||
|
||||
@@ -784,6 +784,90 @@ static const FFlogo* getLogoMintOld()
|
||||
FF_LOGO_RETURN
|
||||
}
|
||||
|
||||
static const FFlogo* getLogoNixOS()
|
||||
{
|
||||
FF_LOGO_INIT
|
||||
FF_LOGO_NAMES("nixos", "nix", "nixos-linux", "nix-linux", "nix-os", "nix_os", "nix_os_linux")
|
||||
FF_LOGO_LINES(
|
||||
"$1 ▗▄▄▄ $2▗▄▄▄▄ ▄▄▄▖\n"
|
||||
"$1 ▜███▙ $2▜███▙ ▟███▛\n"
|
||||
"$1 ▜███▙ $2▜███▙▟███▛\n"
|
||||
"$1 ▜███▙ $2▜██████▛\n"
|
||||
"$1 ▟█████████████████▙ $2▜████▛ $1▟▙\n"
|
||||
"$1 ▟███████████████████▙ $2▜███▙ $1▟██▙\n"
|
||||
"$2 ▄▄▄▄▖ ▜███▙ $1▟███▛\n"
|
||||
"$2 ▟███▛ ▜██▛ $1▟███▛\n"
|
||||
"$2 ▟███▛ ▜▛ $1▟███▛\n"
|
||||
"$2▟███████████▛ $1▟██████████▙\n"
|
||||
"$2▜██████████▛ $1▟███████████▛\n"
|
||||
"$2 ▟███▛ $1▟▙ ▟███▛\n"
|
||||
"$2 ▟███▛ $1▟██▙ ▟███▛\n"
|
||||
"$2 ▟███▛ $1▜███▙ ▝▀▀▀▀\n"
|
||||
"$2 ▜██▛ $1▜███▙ $2▜██████████████████▛\n"
|
||||
"$2 ▜▛ $1▟████▙ $2▜████████████████▛\n"
|
||||
"$1 ▟██████▙ $2▜███▙\n"
|
||||
"$1 ▟███▛▜███▙ $2▜███▙\n"
|
||||
"$1 ▟███▛ ▜███▙ $2▜███▙\n"
|
||||
"$1 ▝▀▀▀ ▀▀▀▀▘ $2▀▀▀▘"
|
||||
)
|
||||
FF_LOGO_COLORS(
|
||||
"34", //blue
|
||||
"36" //cyan
|
||||
)
|
||||
FF_LOGO_RETURN
|
||||
}
|
||||
|
||||
static const FFlogo* getLogoNixOsOld()
|
||||
{
|
||||
FF_LOGO_INIT
|
||||
FF_LOGO_NAMES("nixos_old", "nix-old", "nixos-old", "nix_old", "nix-os-old", "nix_os_old")
|
||||
FF_LOGO_LINES(
|
||||
"$1 ::::. $2'::::: ::::'\n"
|
||||
"$1 '::::: $2':::::. ::::'\n"
|
||||
"$1 ::::: $2'::::.:::::\n"
|
||||
"$1 .......:::::..... $2::::::::\n"
|
||||
"$1 ::::::::::::::::::. $2:::::: $1::::.\n"
|
||||
" ::::::::::::::::::::: $2:::::. $1.::::'\n"
|
||||
"$2 ..... ::::' $1:::::'\n"
|
||||
"$2 ::::: '::' $1:::::'\n"
|
||||
"$2 ........::::: ' $1:::::::::::.\n"
|
||||
"$2::::::::::::: $1:::::::::::::\n"
|
||||
"$2 ::::::::::: $1.. $1:::::\n"
|
||||
"$2 .::::: $1.::: $1:::::\n"
|
||||
"$2 .::::: $1::::: $1''''' $2.....\n"
|
||||
" ::::: $1':::::. $2......:::::::::::::'\n"
|
||||
" ::: $1::::::. $2':::::::::::::::::'\n"
|
||||
"$1 .:::::::: $2'::::::::::\n"
|
||||
"$1 .::::''::::. $2'::::.\n"
|
||||
"$1 .::::' ::::. $2'::::.\n"
|
||||
"$1 .:::: :::: $2'::::."
|
||||
)
|
||||
FF_LOGO_COLORS(
|
||||
"34", //blue
|
||||
"36" //cyan
|
||||
)
|
||||
FF_LOGO_RETURN
|
||||
}
|
||||
|
||||
static const FFlogo* getLogoNixOsSmall()
|
||||
{
|
||||
FF_LOGO_INIT
|
||||
FF_LOGO_NAMES("nixos_small", "nix-small", "nixos-small", "nix_small", "nix-os-small", "nix_os_small")
|
||||
FF_LOGO_LINES(
|
||||
"$1 \\\\ \\\\ //\n"
|
||||
" ==\\\\__\\\\/ //\n"
|
||||
" // \\\\//\n"
|
||||
"==// //==\n"
|
||||
" //\\\\___//\n"
|
||||
"// /\\\\ \\\\==\n"
|
||||
" // \\\\ \\\\"
|
||||
)
|
||||
FF_LOGO_COLORS(
|
||||
"34" //blue
|
||||
)
|
||||
FF_LOGO_RETURN
|
||||
}
|
||||
|
||||
static const FFlogo* getLogoOpenSuse()
|
||||
{
|
||||
FF_LOGO_INIT
|
||||
@@ -1162,6 +1246,9 @@ static GetLogoMethod* getLogos()
|
||||
getLogoMint,
|
||||
getLogoMintSmall,
|
||||
getLogoMintOld,
|
||||
getLogoNixOS,
|
||||
getLogoNixOsOld,
|
||||
getLogoNixOsSmall,
|
||||
getLogoOpenSuse,
|
||||
getLogoOpenSuseSmall,
|
||||
getLogoOpenSuseLeap,
|
||||
|
||||
+69
-2
@@ -136,6 +136,48 @@ static uint32_t countFilesIn(const char* dirname, const char* filename)
|
||||
return result;
|
||||
}
|
||||
|
||||
static uint32_t getNixPackages(const FFstrbuf* path)
|
||||
{
|
||||
FFstrbuf output;
|
||||
ffStrbufInitA(&output, 128);
|
||||
|
||||
ffProcessAppendStdOut(&output, (char* const[]) {
|
||||
"nix-store",
|
||||
"-qR",
|
||||
path->chars,
|
||||
NULL
|
||||
});
|
||||
|
||||
//Each package is a new line in the output. If at least one line is found, add 1 for the last line.
|
||||
uint32_t result = ffStrbufCountC(&output, '\n');
|
||||
if(result > 0)
|
||||
result++;
|
||||
|
||||
ffStrbufDestroy(&output);
|
||||
return result;
|
||||
}
|
||||
|
||||
static uint32_t getNixPackagesDefault()
|
||||
{
|
||||
FFstrbuf path;
|
||||
ffStrbufInitA(&path, 64);
|
||||
ffStrbufAppendS(&path, FASTFETCH_TARGET_DIR_ROOT"/nix/var/nix/profiles/default");
|
||||
uint32_t result = getNixPackages(&path);
|
||||
ffStrbufDestroy(&path);
|
||||
return result;
|
||||
}
|
||||
|
||||
static uint32_t getNixPackagesUser(const FFinstance* instance)
|
||||
{
|
||||
FFstrbuf path;
|
||||
ffStrbufInitA(&path, 64);
|
||||
ffStrbufAppendS(&path, instance->state.passwd->pw_dir);
|
||||
ffStrbufAppendS(&path, "/.nix-profile");
|
||||
uint32_t result = getNixPackages(&path);
|
||||
ffStrbufDestroy(&path);
|
||||
return result;
|
||||
}
|
||||
|
||||
void ffPrintPackages(FFinstance* instance)
|
||||
{
|
||||
uint32_t pacman = getNumElements(FASTFETCH_TARGET_DIR_ROOT"/var/lib/pacman/local", DT_DIR);
|
||||
@@ -149,6 +191,17 @@ void ffPrintPackages(FFinstance* instance)
|
||||
|
||||
uint32_t emerge = countFilesIn(FASTFETCH_TARGET_DIR_ROOT"/var/db/pkg", "SIZE");
|
||||
uint32_t xbps = getNumElements(FASTFETCH_TARGET_DIR_ROOT"/var/db/xbps", DT_REG);
|
||||
|
||||
uint32_t nixUser = 0;
|
||||
uint32_t nixDefault = 0;
|
||||
|
||||
//Nix detection is kinda slow, so we only do it if the nix dir exists
|
||||
if(ffFileExists(FASTFETCH_TARGET_DIR_ROOT"/nix", S_IFDIR))
|
||||
{
|
||||
nixUser = getNixPackagesUser(instance);
|
||||
nixDefault = getNixPackagesDefault();
|
||||
}
|
||||
|
||||
uint32_t flatpak = getNumElements(FASTFETCH_TARGET_DIR_ROOT"/var/lib/flatpak/app", DT_DIR);
|
||||
uint32_t snap = getNumElements(FASTFETCH_TARGET_DIR_ROOT"/snap", DT_DIR);
|
||||
|
||||
@@ -156,7 +209,7 @@ void ffPrintPackages(FFinstance* instance)
|
||||
if(snap > 0)
|
||||
--snap;
|
||||
|
||||
uint32_t all = pacman + dpkg + rpm + emerge + xbps + flatpak + snap;
|
||||
uint32_t all = pacman + dpkg + rpm + emerge + xbps + nixUser + nixDefault + flatpak + snap;
|
||||
|
||||
if(all == 0)
|
||||
{
|
||||
@@ -193,7 +246,21 @@ void ffPrintPackages(FFinstance* instance)
|
||||
FF_PRINT_PACKAGE(dpkg)
|
||||
FF_PRINT_PACKAGE(rpm)
|
||||
FF_PRINT_PACKAGE(emerge)
|
||||
FF_PRINT_PACKAGE(xbps)
|
||||
|
||||
if(nixUser > 0)
|
||||
{
|
||||
printf("%u (nix-user)", nixUser);
|
||||
if((all = all - nixUser) > 0)
|
||||
printf(", ");
|
||||
}
|
||||
|
||||
if(nixDefault > 0)
|
||||
{
|
||||
printf("%u (nix-default)", nixDefault);
|
||||
if((all = all - nixDefault) > 0)
|
||||
printf(", ");
|
||||
}
|
||||
|
||||
FF_PRINT_PACKAGE(flatpak)
|
||||
FF_PRINT_PACKAGE(snap)
|
||||
|
||||
|
||||
@@ -495,6 +495,17 @@ bool ffStrbufEndsWithS(const FFstrbuf* strbuf, const char* end)
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t ffStrbufCountC(const FFstrbuf* strbuf, char c)
|
||||
{
|
||||
uint32_t result = 0;
|
||||
for(uint32_t i = 0; i < strbuf->length; i++)
|
||||
{
|
||||
if(strbuf->chars[i] == c)
|
||||
result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool testEndsWithIgnCaseS(const FFstrbuf* strbuf, const char* end, uint32_t* endLength)
|
||||
{
|
||||
*endLength = (uint32_t) strlen(end);
|
||||
|
||||
@@ -87,6 +87,8 @@ bool ffStrbufStartsWithIgnCaseS(const FFstrbuf* strbuf, const char* start);
|
||||
bool ffStrbufEndsWithC(const FFstrbuf* strbuf, char c);
|
||||
bool ffStrbufEndsWithS(const FFstrbuf* strbuf, const char* end);
|
||||
|
||||
uint32_t ffStrbufCountC(const FFstrbuf* strbuf, char c);
|
||||
|
||||
bool ffStrbufRemoveIgnCaseEndS(FFstrbuf* strbuf, const char* end);
|
||||
|
||||
void ffStrbufWriteTo(const FFstrbuf* strbuf, FILE* file);
|
||||
|
||||
Reference in New Issue
Block a user