Hostname-based flake.lock


I’m in the process of converting my old nix configs to a flake-based one. The problem I see is that I have one computer tracking 20.09, another unstable. So a single flake.nix won’t track both.

I tried to put flake.lock in .gitignore, but nix tries to force commit it. Could we have a hostname-based lock system, for example, lock files are placed in locks/<hostname>.lock?

Can you use a different name for each input instead?


This has worked for me to cover the distinction of Darwin/non-Darwin channels.

+1 for the having multiple inputs to track different channels.

If you’re trying to use a single input to point at different channels, wouldn’t that also mean you’d have to be manually switching the input’s URL between each machine every time?

I do as well have one computer on unstable, while the remaining 2 are on 20.09.

The trick is to use the nixosSystem function of the channel you want to use as the main channel.


I think multi-channel is a great idea that I’m just too dumb to realize, will try it once I have time.

Still, if we have a nixos and nixos-stable channels as inputs, by default flake would update both at once with:

nix flake update --recreate-lock-file

So I need to only update specific inputs when doing updates to not accidentally update channels for other computers, is that right?

1 Like

As you can see in my makefile, updating a single input is doable as well.

1 Like

Suppose I have 2 machines both tracking unstable, would it be possible to pin them at different commits?

I think I can define unstable-machineA and unstable-machineB and use these inputs accordingly, but this doesn’t look nice.

But this is how you do it. Though just use the same for both… It makes it easier to compare machines if you know that software on both have the same version

1 Like

Well, I guess I’m just nitpicking too much, and I agree I should try to track the same commit on all machines that use the channel.

Another similar corner case is: Mix-match between stable and unstable channel, but I guess your suggestion should also apply here: Track the same commit for both channels on all machines that use them.