Skip to content

Improve detect NixOS packages #195

@Izorkin

Description

@Izorkin

The current way to find installed packages does not work correctly:

fastfetch | grep Packages
Packages: 83 (nix-user)

Actually only a few packages are installed:

nix-env -q
dar-2.7.6
oil-0.11.0

find /etc/profiles/per-user/$USER/bin/ -type l -exec readlink {} \; | sed -E 's|[^-]+-([^/]+)/.*|\1|g' | sort -u
duf-0.8.1
fio-3.30
inxi-3.3.04-1

It is needing to show the number of system packages (may take up to several seconds) - (nix-system):

find /run/current-system/sw/bin/ -type l -exec readlink {} \; | sed -E 's|[^-]+-([^/]+)/.*|\1|g' | sort -u | wc
     90      90    1367

Users packages - (nix-user):

find ~/.nix-profile/bin -type l -exec readlink {} \; | sed -E 's|[^-]+-([^/]+)/.*|\1|g' | sort -u | wc
     2       2      21
find /etc/profiles/per-user/$USER/bin -type l -exec readlink {} \; | sed -E 's|[^-]+-([^/]+)/.*|\1|g' | sort -u | wc
      3       3      33

Default packages - (nix-default):

find /nix/var/nix/profiles/default/bin -type l -exec readlink {} \; | sed -E 's|[^-]+-([^/]+)/.*|\1|g' | sort -u | wc
     1       1      17

Other methods do not give the exact number of packages installed

This method found in https://discourse.nixos.org/t/can-i-inspect-the-installed-versions-of-system-packages/2763/18

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions