gytis-ivaskevicius / flake-utils-plus

Use Nix flakes without any fluff.
MIT License
485 stars 57 forks source link

Print which host is being built #108

Closed noonien closed 3 months ago

noonien commented 2 years ago

When doing remote builds with flakes, sometimes it's not obvious which host is being built. --flake . might build the wrong host. The fix for this is usually just to use --flake .#host, however, if you nixos-rebuild switch, it might have already switched to the wrong configuration.

In the past, before using flake-utils-plus, i just had builtins.trace "building ${name}" <actual builder>, which did the job.

Even though I think this might be a good idea, others may disagree. So it would be nice to either be able just opt-in to this, or just be able to setup a default builder, and not have to define a builder for each host.

fufexan commented 2 years ago

If I'm not mistaken you could do

hostDefaults.builder = builtins.trace "building ${name}" <actual builder>
gytis-ivaskevicius commented 2 years ago

I am not sure what is the solution here. @noonien what do you think is the correct way of implementing it?

noonien commented 2 years ago

I've currently removed the builtins.trace from my nix files, and print which host is being built in my own deploy script. But I believe fufexan's solution might be good enough, perhaps as an opt-out default?

voidzero commented 1 year ago

I like it. I plan on using a single flake for about 10 servers. I'm sure I'll mess things up sooner or later, at least this will help me catch mistakes early.