How do I count the number of nixpkgs packages?
You could copy whatever neofetch does?
I updated the title. It’s just that in Arch, I can count the number of packages in AUR in this manner:
paru -Sal | wc -l
It’s simple, but I don’t know how to do it on Nixpkgs, though.
Also, neofetch is an abandoned project; there’s fastfetch.
Hello,
Is this helping ? This snippet will count the amount of available packages for x86_64-linux architecture.
❯ cd nixpkgs
❯ nix repl .
Nix 2.28.5
Type :? for help.
Loading installable 'git+file:///home/pol/Code/NixOS/nixpkgs#'...
Added 7 variables.
nix-repl> :lf .
Added 19 variables.
nix-repl> pkgs = import <nixpkgs> { }
nix-repl> lib = pkgs.lib
nix-repl> lib.count (_: true) (builtins.attrNames outputs.legacyPackages.x86_64-linux)
25787
I’m pretty sure there are easier ways to do that using a one-liner, but I don’t really know how to do it.
Okay, look at the packages.json generated for the tarballs.
curl -L 'https://channels.nixos.org/nixos-unstable/packages.json.br' -o - |
brotli -d |
jq -r '.packages | length'
If you have Nix and you want to know the number of packages for the architecture:
❯ cd nixpkgs
❯ nix repl .
Nix 2.28.5
Type :? for help.
Loading installable 'git+file:///home/pol/Code/NixOS/nixpkgs#'...
Added 7 variables.
nix-repl> :lf .
Added 19 variables.
nix-repl> pkgs = import <nixpkgs> { }
nix-repl> lib = pkgs.lib
nix-repl> lib.count (_: true) (builtins.attrNames outputs.legacyPackages.x86_64-linux)
25787
If you don’t have Nix and you just want to look at the overall number of packages for every architecture:
curl -L 'https://channels.nixos.org/nixos-unstable/packages.json.br' -o - |
brotli -d |
jq -r '.packages | length'
Yeah, but this skips out on all packages which are nested (python3Packages, Haskell packages, etc.)
Instead, here’s the official from-Hydra count over time.
It shows overall packages, including other architectures.
That’s the second method, yes? The first method was the one that I reacted to as skipping out on nested packages.
The count from Hydra that I posted, just for clarity, is for x86_64-linux as a representative architecture.