nh icon indicating copy to clipboard operation
nh copied to clipboard

implement `nixos-rebuild list-generations`

Open NotAShelf opened this issue 1 year ago • 3 comments

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                   *

NotAShelf avatar Jun 02 '24 00:06 NotAShelf

Some time ago I planned a nh os info subcommand, perhaps we could show more useful info

viperML avatar Jun 02 '24 08:06 viperML

What else would you like to display? I was going to pick apart the list-generations subcommand, so we can definitely add more data

NotAShelf avatar Jun 02 '24 10:06 NotAShelf

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

viperML avatar Jun 02 '24 17:06 viperML

commenting to refloat this

Vortriz avatar Oct 21 '24 07:10 Vortriz

I was working on this :(

NotAShelf avatar Oct 21 '24 08:10 NotAShelf

:)

NotAShelf avatar Oct 21 '24 09:10 NotAShelf

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

Vortriz avatar Oct 21 '24 10:10 Vortriz

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.

NotAShelf avatar Oct 21 '24 10:10 NotAShelf

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.

NotAShelf avatar Dec 11 '24 05:12 NotAShelf

Closed by #198

NotAShelf avatar Mar 13 '25 03:03 NotAShelf