A tool for looking if installed packages are up to date?


Is there an equivalent in nix to guix refresh ? see guix documentation

When running this command, it looks for installed package, search if upstream (not nixpkgs, but the software upstream) has a newer version and report it. That’s handy to find updates for software we are using.

1 Like

If upstream is nixpkgs, I use nvd (Nvd: Simple Nix/NixOS version diff tool):

which is part of a nixos-rebuild build --upgrade | nix-output-monitor ; nvd $currentsystem $builtsystem with a prompt asking me if I want to upgrade.
If I don’t, channel is rollbacked.

I guess that reusing the appstream metadata stuff for Software Center, it should be possible to build a true command that will ask upstream in reasonable scenarios, e.g. proper upstream metadata.

1 Like

That’s cool!

However I’m looking for a program to tell me which package I use in nixpkgs should be updated in nixpkgs :slight_smile:

I think the closest equivalent is the nixpkgs-update tool that automatically updates packages in nixpkgs. See a recent example PR https://github.com/NixOS/nixpkgs/pull/190934

That tool essentially replaces the need to run guix refresh locally, since it monitors when any package in Nixpkgs can be updated. Assuming of course it knows how to update it.

Thank you, I’ll give it a try. However I need to find a way to feed it with packages installed on my computer. I prefer to focus on those :slight_smile:

I personally instantiate the system locally and diff against repology's database. I’m using very hacky bash and jq. Would be nice to have a better maintained tool :slight_smile: Example session (it compares against staging local branch):

$ ./fetch_outadted_packages.bash
$ ./print_local_outdated.bash
# installed(staging): unstable(master) -> latest(others)
afdko-3.9.0:   "afdko": "python3.10-afdko: 3.9.0 -> 3.9.1",
alsa-ucm-conf-   "alsa-ucm-conf": "alsa-ucm-conf: ->",
attica-5.97.0:   "attica": "attica: 5.97.0 -> 5.98.0",
audit-2.8.5:   "audit": "audit: 2.8.5 -> 3.0.9",
autoconf-archive-2022.02.11:   "autoconf-archive": "autoconf-archive: 2022.02.11 -> 2022.09.03",
autogen-5.18.16:   "autogen": "autogen: 5.18.16 -> 5.19.96",
aws-c-common-0.7.4:   "aws-c-common": "aws-c-common: 0.7.4 -> 0.8.1",
aws-c-io-0.13.3:   "aws-c-io": "aws-c-io: 0.13.3 -> 0.13.4",
aws-crt-cpp-0.17.32:   "aws-crt-cpp": "aws-crt-cpp: 0.17.32 -> 0.18.5",
aws-c-s3-0.1.46:   "aws-c-s3": "aws-c-s3: 0.1.46 -> 0.1.47",
aws-sdk-cpp-1.9.294:   "aws-sdk-cpp": "aws-sdk-cpp: 1.9.294 -> 1.9.340",
bcache-tools-1.0.7:   "bcache-tools": "bcache-tools: 1.0.7 -> 1.1",
blas-3:   "blas": "blas: 3 -> 3.10.1",
boost-1.79.0:   "boost": "boost: 1.59.0 -> 1.80.0",

Gory details (complete implementation):

#! /usr/bin/env bash
# cat installed.bash

nix show-derivation --derivation -r $(nix-instantiate ~/n/nixos -A system) |
    jq -r '.[] | "\(.env.pname) \(.env.version)"' | fgrep -v "null" | sort -u
#!/usr/bin/env bash
# cat fetch_outadted_packages.bash

rm -rfv d
mkdir -p d

while :; do
    echo "Fetching '$suffix'"
    curl --compressed -s "https://repology.org/api/v1/projects/${suffix:+${suffix}/}?inrepo=nix_unstable&outdated=1" > "d/l_${suffix}"
    next=$(jq --sort-keys --raw-output 'keys|last' < "d/l_${suffix}")
    [[ $suffix == $next ]] && break

# TODO print:
# - nixpkgs version
# - newest version
# - nixpkgs name
for f in d/l_*; do
jq --sort-keys '

  "newest": map(
  "nix_unstable_version": map(
  "nix_name": map(
})' <"${f}" |
# pretty print"
jq --sort-keys '
    "\(.nix_name): \(.nix_unstable_version) -> \(.newest)"

done > d/l
#! /usr/bin/env bash
# cat print_local_outdated.bash

echo "# installed(staging): unstable(master) -> latest(others)"
./installed.bash |
while read l; do
    set -- $l
    #echo "$p - $v"
    if [[ $(fgrep '"'"$p"'"' d/l | fgrep -v -- '-> '"$v"'"' | wc -l) -gt 0 ]]; then
        echo -n "$p-$v: "
        fgrep '"'"$p"'"' d/l | fgrep -v -- '-> '"$v"'"'

This is working fine! :star_struck:

That’s a really cool idea. Makes it easy to see where upstream might need some help with things I actually use.

1 Like

I ended up writing a tool for that as I kept bumping into smaller corner cases that were not handled by simple grep: GitHub - trofi/nix-olde: Show details about outdated packages in your NixOS system.. Now the output looks like that (~/n is nixpkgs/staging):

$ ./mkrun.bash -n ~/n
Fetching 'installed' ...
Fetching 'available' ...
Fetching 'repology' ...
... 'available' done.
... 'installed' done.
... 'repology' done.
repology a52dec "0.8.0" | nixpkgs {"0.7.4"} {"a52dec"}
repology alsa-lib "1.2.8" | nixpkgs {""} {"alsa-lib"}
repology alsa-ucm-conf "1.2.8" | nixpkgs {""} {"alsa-ucm-conf"}
repology appstream "0.15.6" | nixpkgs {"0.15.5"} {"appstream"}
repology xprop "1.2.6" | nixpkgs {"1.2.5"} {"xorg.xprop"}
repology xrandr "1.5.2" | nixpkgs {"1.5.1"} {"xorg.xrandr"}
repology xset "1.2.5" | nixpkgs {"1.2.4"} {"xorg.xset"}
repology xsetroot "1.1.3" | nixpkgs {"1.1.2"} {"xorg.xsetroot"}
repology xterm "378" | nixpkgs {"377"} {"xterm"}
repology zxing-cpp-nu-book "2.0.0" | nixpkgs {"1.4.0"} {"zxing-cpp"}