Closed Gobidev closed 5 months ago
As long as the numbers are accurate, this looks like a neat solution. I kinda sorta wish more package managers kept a little SQLite database like rpm
does, it makes things simple.
Yea it would be nice to have something like that, I looked through nix
source code for a while and tried to figure out how their method works but it seemed to complicated to replicate.
This doesn't look like it's discounting duplicates, which means that, for example, two bash
entries in /nix/store
are viewed as two distinct packages. I presume this is what makes the nix implementation complex. In any case, we should try to match their counting mechanism in order to report correct information.
Sounds good, I will try to replicate the count method of nix-store
when I have more time. Btw, can you make a release in the near future? It would be nice to have easy access to the features of the past few months.
Sure thing, I'll get to that tomorrow.
See #172
closes #120
This PR adds nix package count. It works by counting the amount of directories in
/nix/store/
and filtering out the ones that don't have a version number in their package name. This value differs from runningnix-store -q --requisites /run/current-system/sw | wc -l
andnix-store -q --requisites ~/.nix-profile | wc -l
and adding the values (method used by other fetch utilities) because the directory also contains packages that are not counted bynix-store -q
. However, spawning the commands is not an option as they both take around .3s to execute which is way longer than all other readouts combined take to run. This is the best alternative I could find.To get an idea of how much they differ, here are some numbers:
nix-store -q ...
nix-store -q ...
I also simplified the
count_snap
function by replacing theif let ... return
withmap()