NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.77k stars 1.52k forks source link

have `nix flake update` better explain changes #10015

Open KiaraGrouwstra opened 9 months ago

KiaraGrouwstra commented 9 months ago

Is your feature request related to a problem? Please describe. Using flakes in version control allows one to fully trace what changed among your dependencies. And in fact, commands like nix flake update --commit-lock-file definitely facilitate this, committing messages along the lines of:

flake.lock: 

Flake lock file updates:

• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/442d407992384ed9c0e6d352de75b69079904e4e' (2024-02-09)
  → 'github:nixos/nixpkgs/89653a03e0915e4a872788d10680e7eec92f8600' (2024-02-14)

This level of traceability is awesome, allowing users to:

While there are limits to what we can automate of those processes, I feel we might be able to improve a bit on the level of info we offer there now.

Describe the solution you'd like In commit messages for example, it could already be valuable to allow having it add info on package version updates, e.g.:

• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/442d407992384ed9c0e6d352de75b69079904e4e' (2024-02-09)
  → 'github:nixos/nixpkgs/89653a03e0915e4a872788d10680e7eec92f8600' (2024-02-14)
    • vim: 1.2.3 → 1.2.4

However, for interfaces more aimed at humans, I feel we could also go further than that, like adding hyperlinks to find out more about:

Describe alternatives you've considered stare at a list of hashes, then run

Additional context i am a fallible human being failing to always verify which packages got updated between two commit hashes

thibaultmol commented 8 months ago

I started with Nix recently and also stumbled into this. It's very nice that I can update from one locked state to another locked state. But it would be great if you could see exactly what packages updates between each lock. Like a chanelog basically

thufschmitt commented 8 months ago

This looks rather hard to do. A Nixpkgs update is likely to involve updating thousands of packages, and there's no real way to know which ones are relevant in the general case.

There could be something (but probably not built into Nix) that could add some nix diff-closures on top:

#!/usr/bin/env bash

set -euo pipefail

before_update=$(nix build --no-link --print-out-paths .)
nix flake update
after_update=$(nix build --no-link --print-out-paths .)

nix store diff-closures "$before_update" "$after_update"
 $ bash diff-closure.sh
• Updated input 'nixpkgs':
    'path:/nix/store/yy19v2dwb8ldphvia9smajvwv3ycx2c1-source?lastModified=1705331948&narHash=sha256-qjQXfvrAT1/RKDFAMdl8Hw3m4tLVvMCc8fMqzJv0pP4%3D&rev=b8dd8be3c790215716e7c12b247f45ca525867e2' (2024-01-15)
  → 'github:nixos/nixpkgs/70bdadeb94ffc8806c0570eb5c2695ad29f0e421' (2024-01-03)
bash: -41.3 KiB
gawk: 5.2.1 → 5.2.2, +15.0 KiB
glibc: 2.37-45 → 2.38-27
vim: 9.0.1441 → 9.0.2048, +860.4 KiB
xgcc: 12.2.0 → 12.3.0
KiaraGrouwstra commented 8 months ago

i'd mostly mentioned packages from flake-based sources, tho i guess nix flake update also updates non-flake sources. for those i wonder if we could read git tags associated with commits included in an update to get a sense of versions updated to. perhaps that would be more of a follow-up to the present ticket tho.

gmile commented 4 months ago

For reference, a similar topic was also discussed in discourse relatively recently: https://discourse.nixos.org/t/what-packages-will-get-updated/36057.

The commands referenced there did give me some sense of what got upgraded:

nix store diff-closures /run/*-system/

Output:

docker: 26.1.3 → 26.1.4
docker-containerd: 26.1.3 → 26.1.4
docker-init: 26.1.3 → 26.1.4
docker-runc: 26.1.3 → 26.1.4
initrd-linux: 6.6.32 → 6.6.33
linux: 6.6.32, 6.6.32-modules → 6.6.33, 6.6.33-modules, -667.3 KiB
moby: 26.1.3 → 26.1.4
nixos-system-nixos: 24.05.20240609.2819fff → 24.05.20240615.752c634
source: +68.3 KiB

However, my flake contains more stuff, packages installed using home-manager - I am not sure how to check if those packages (for example, neovim, jq, etc.) are listed here 🤔