Unverified Commit ba691700 authored by Rick van Schijndel's avatar Rick van Schijndel Committed by GitHub
Browse files

ufetch: init at 0.3 (#266274)

parents 57ff99d7 5177bf33
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
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() {
+47 −0
Original line number Diff line number Diff line
{
  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 ];
  };
})