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

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-1.2.7.1:   "alsa-ucm-conf": "alsa-ucm-conf: 1.2.7.1 -> 1.2.7.2",
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

suffix=
while :; do
    #break
    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
    suffix=$next
done

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

map_values({
  "newest": map(
    select(.status|in({"newest":1}))
  )|first(.[].version),
  "nix_unstable_version": map(
    select(.repo|in({"nix_unstable":1}))
  )|first(.[].version),
  "nix_name": map(
    select(.repo|in({"nix_unstable":1}))
  )|first(.[].name),
})' <"${f}" |
# pretty print"
jq --sort-keys '
  map_values(
    "\(.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
    p=$1
    v=$2
    #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"'"'
    fi
done
7 Likes