ufetch: init at 0.3 (#266274)

This commit is contained in:
Rick van Schijndel 2024-11-23 22:34:34 +01:00 committed by GitHub
commit ba69170047
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,20 @@
diff --git a/ufetch-nixos b/ufetch-nixos
index 2ca8f9d..5102cd7 100755
--- a/ufetch-nixos
+++ b/ufetch-nixos
@@ -9,9 +9,14 @@ host="$(hostname)"
os="$(nixos-version)"
kernel="$(uname -sr)"
uptime="$(uptime | awk -F, '{sub(".*up ",x,$1);print $1}' | sed -e 's/^[ \t]*//')"
-packages="$(ls -d -1 /nix/store/*/ | wc -l)"
shell="$(basename "${SHELL}")"
+for profile in $NIX_PROFILES; do
+ if [ -d "$profile" ]; then
+ packages="$((packages + $( (nix-store -q --requisites "$profile" 2>/dev/null || true) | wc -l)))"
+ fi
+done
+
## UI DETECTION
parse_rcs() {

View File

@ -0,0 +1,47 @@
{
stdenvNoCC,
fetchFromGitLab,
lib,
full ? true,
# see https://gitlab.com/jschx/ufetch for a list
osName ? "nixos",
}:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "ufetch";
version = "0.3";
src = fetchFromGitLab {
owner = "jschx";
repo = "ufetch";
rev = "v${finalAttrs.version}";
hash = "sha256-1LtVCJrkdI2AUdF5d/OBCoSqjlbZI810cxtcuOs/YWs=";
};
patches = [ ./0001-optimize-packages-command.patch ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin $out/share/licenses/${finalAttrs.pname}
${
if !full then
"install -Dm755 ufetch-${osName} $out/bin/ufetch"
else
''
install -Dm755 ufetch-* $out/bin
ln -s $out/bin/ufetch-${osName} $out/bin/ufetch
''
}
install -Dm644 LICENSE $out/share/licenses/${finalAttrs.pname}/LICENSE
runHook postInstall
'';
meta = {
description = "Tiny system info for Unix-like operating systems";
homepage = "https://gitlab.com/jschx/ufetch";
license = lib.licenses.mit;
platforms = lib.platforms.linux;
mainProgram = "ufetch";
maintainers = with lib.maintainers; [ mrtnvgr ];
};
})