Give name/label/comment to generations?

I would like to know what I will get if I restore a certain generation. Can I assign a name/label/comment to a previous generation?

1 Like

i do not know how to apply labels retroactively, but if you can be proactive about labeling things before deploying them then system.nixos.label is relevant. it should be possible to populate this with the git branch name or at least the short rev if you have your config under version control.

3 Likes

Nice, TIL.

I have this, to populate the nixos-version configurationRevision field so I know the config, not just the nixpkgs revision:

system.configurationRevision = let self = inputs.self; in self.shortRev or self.dirtyShortRev or self.lastModified or "unknown";

Adding the branch name is probably a good idea, and using it to make a label seems to make it even more useful.

2 Likes

This is what nixos-rebuild --profile-name is for (isn’t it?) - that’s not declarative though.

Another way to do it:

NIXOS_LABEL="changed-some-settings" nixos-rebuild switch