Is there a way to add a comment on each nixos-rebuild, just like git?

I’d like to have some comment to track what I did.

Something like this?

https://nixos.org/nixos/options.html#system.nixos.label

So, if you Git your configuration, and do rebuilds after commiting code, you can include

your local Git rev (or even partial Git commit message) to each boot entry.

That’s really cool~ Thanks~!

Those labels are nice, I have aliased “nixos-rebuild switch” to automatically sync with github at the same time, sharing commit messages/labels. The message also just defaults to some basic info pulled from “git status” if I’m too lazy to write one. You can definitely wrap your git-rev in there in a similar way to how I have it include commit info.

Even nicer would be if the label could be passed to nixos-rebuild, for folks like me who are mostly concerned about tagging what changes i made to the config.nix in each rebuild.

You can set it quickly using the “NIXOS_LABEL” and “NIXOS_LABEL_VERSION” environment variables rather than editing your config. This is how my scripts handle it.
I more or less added this to my a wrapper for rebuilding: export NIXOS_LABEL=$(git status | grep 'pull out some relevant lines...' ); nixos-rebuild switch

The options description provides a similar script suggestion
https://nixos.org/nixos/options.html#system.nixos.label

3 Likes

That would be great - I’m looking at the grub list thinking when did I install that thing?