Can you tag builds?

I’ve been nixos-curious for quite some time. Got a new laptop and decided it was time to take the plunge.

My question: Is it possible to tag/name your nixos builds (nixos-rebuild result)?

What I’m trying to accomplish: I’d like to keep a working Gnome build, so I can just get stuff done. But I’d also like to play with having a minimal hyprland install. My thought was I could iterate on the hyprland side, but fall back to Gnome by just rebooting and picking it out of the boot menu. For now, I’ve just been solving this by keeping a separate branch and doing a rebuild every time I switch. Having the ability to name a build (better name for this?) would be cool, if it’s possible.

What about versioning your configuration with Git and using branches to switch?

I actually always used flakes (an extensive guide for that could be, but I guess you should be able to do it even with the classic configuration.nix. I guess symlinking could work.

Otherwise, you may want to have a look to:

EDIT: btw, with flakes (at least) you don’t even need Git branches, since you can manage multiple configurations at a time, and just pick the one to install with

nixos-rebuild switch --flake /path/to/flake#config1

(again, I expect configuration.nix to allow something like that, I’m just not too familiar with it)

1 Like

Thanks for the reply!

I’m actually doing this already (symlinking to ~/nixos and using branches). I’m trying to ease myself into all of this, since I need to be somewhat productive while I play with things. I am planning on going to flakes and home-manager once I have a grasp on it, but your comment is making me think I should explore flakes to ease my other explorations. Good thoughts.

Still, it’d be nice to know if you could somehow tag builds for the boot menu. But it may not be all that useful in practice.

Oh! RTF Man pages, maybe: nixos-rebuild: reconfigure a NixOS machine | NixOS System Administration | Man Pages | ManKier

Looks like --profile-name gives me what I was asking for in the systemd-boot menu.

Actually, I had in mind you wanted to maintain multiple sources, not multiple builds, sorry (that’s usually the case when you have multiple machines, since - at order 0 - you will rebuild on each machine).
I saw the -I in the man pages (which is not quite documented there…), and that’s what to use for multiple sources, but it seems very similar to switching branches, and versioning has many pros.

However, if you want to use profiles, the proper reference is:
but I believe they are truly useful only with the imperative approach, since they maintain a state for you (i.e. using nix-env).

If you go declarative (both configuration.nix and flakes), I’m not so sure how much they are going to be useful. Consider that, if you do not customize them, packages from nixpkgs are coming pre-built, and both w/ and w/o profiles they are ending up in your /nix/store.

So, in imperative style, the profiles are tracking the state of your system for you. In declarative style, it’s already your source tracking the state of your system.

1 Like

Thanks. All super helpful. I’m interested in the more declarative approaches (I mean, that is the most compelling part of nixos, right?), so I’ll start my flake exploration next. Really appreciate your engagement, though I’ll mark my own answer as a solution since it’s a succinct answer to the “tag build” question. Even if it isn’t exactly what I probably want to be doing for my situation.

1 Like