diff --git a/pkgs/by-name/uf/ufetch/0001-optimize-packages-command.patch b/pkgs/by-name/uf/ufetch/0001-optimize-packages-command.patch new file mode 100644 index 000000000000..e303db4968a8 --- /dev/null +++ b/pkgs/by-name/uf/ufetch/0001-optimize-packages-command.patch @@ -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() { diff --git a/pkgs/by-name/uf/ufetch/package.nix b/pkgs/by-name/uf/ufetch/package.nix new file mode 100644 index 000000000000..4e8e3311467a --- /dev/null +++ b/pkgs/by-name/uf/ufetch/package.nix @@ -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 ]; + }; +})