implement `nixos-rebuild list-generations`
I've recently noticed the list-generations option for nixos-rebuild that outputs a neat table of available generations. Maybe we could implement a nh os generations command as a replacement, that returns similar table of data (+ any other data that we might want) as a formatted table or JSON for parsing purposes.
For reference, here's the example output:
Generation Build-date NixOS version Kernel Configuration Revision Specialisation
1689 current 2024-06-02 00:20:26 graphical-workstation-24.11.20240527.9ca3f64 6.9.1-xanmod1 dirty *
1688 2024-05-31 07:53:58 graphical-workstation-24.11.20240527.9ca3f64 6.9.1-xanmod1 dirty *
1687 2024-05-31 07:49:22 graphical-workstation-24.11.20240527.9ca3f64 6.9.1-xanmod1 dirty *
1686 2024-05-29 23:45:01 graphical-workstation-24.11.20240527.9ca3f64 6.9.1-xanmod1 dirty *
Some time ago I planned a nh os info subcommand, perhaps we could show more useful info
What else would you like to display? I was going to pick apart the list-generations subcommand, so we can definitely add more data
I don't know, that's why I didn't write the command in the end 🤣
Though perhaps closure size (nix path-info -Sh) and nixpkgs commit
commenting to refloat this
I was working on this :(
:)
i have some suggestions on what all can be shown upon nh os info:
- size of nix store (if thats useful)
- space saved by hardlinking
Nix itself (as per my knowledge) does not report either of those stats. I can calculate the size of the Nix store, but there are already better tools (du, dust, etc.) which I am not sure if we should bother wrapping.
I've started actually implementing this, as nh os generations. Acts as a convenient alias to nix-env --list-generations or nixos-rebuild list-generations by parsing /nix/var/nix/profiles to discover generations.
Current output:
2649 2024-12-09 03:38:57 graphical-workstation-25.05.20241205.d0797a0 6.12.3-shelf 7612a7fc-dirty
2650 2024-12-10 22:50:12 graphical-workstation-25.05.20241207.22c3f2c 6.12.3-shelf b2be6825-dirty
2651 2024-12-10 23:38:47 graphical-workstation-25.05.20241207.22c3f2c 6.12.4-shelf b2be6825-dirty
2652 2024-12-11 00:37:42 graphical-workstation-25.05.20241207.22c3f2c 6.12.4-shelf 75758fde-dirty
2653 2024-12-11 04:47:10 graphical-workstation-25.05.20241209.a73246e 6.12.4-shelf 88d9419
Not final.
Closed by #198