For inputs, stuff like this seems to be the prevailing convention in flake.nix:
inputs.nixpkgs.url = “github:NixOS/nixpkgs/nixpkgs-unstable”;
- What is the importance of the branch, really? The revision is pinned in the lock file anyway.
- Therefore, the only point of the branch is to instruct what to do if users for some reason want to update my project’s lock file.
- It is in this context that I ask: would users get pissed off if I would put this in my flake.nix instead?
inputs.nixpkgs.url = “github:NixOS/nixpkgs/nixos-22.11”;
- I’m guessing it wouldn’t matter because most users are either going to use my lock file as-is (specific revision) or, even if they replace nixpkgs, that’s going to come from a completely different place (via the
.inputs.nixpkgs.follows
mechanism) - so which branch I pick (for my own convenience) is irrelevant to them.
- Is my guess accurate?
If this points to master, packages will run into cache misses. The revision is pinned in the lockfile by Nix, which will point to something else when you run nix flake update
, which is a fairly regular thing to do.
People shouldn’t be pissed off. A lot of people use unstable branches, and that’s why you see this set to nixos-unstable
all the time. If you are using the flake for yourself, you should probably keep this on the same branch as your NixOS config (if you are using NixOS), otherwise I would default to nixos-unstable
. It does matter in the aspect that if you are not overriding the input, people would need to download a lot more things if they are using unstable. Another thing that you might want to keep in mind is that there are breaking changes that are only present in the unstable branches, so you might want to also test your flake on unstable to make sure that inputs.nixpkgs.follows
works.
One thing that confuses me, different users are going to want a different branch - so why should the branch name be specified at all? It somehow feels more natural that it would be elsewhere and not committed to the repo as it’s not relevant to all users.
1 Like
Users can also use the default, which is the case if you don’t override the inputs.
Because your flake doesn’t necessarily work with the unspecified branches, and there is no way to test that.
Without specifying the branch, things like e.g. nix flake update
would be able to update flake.lock
to something you don’t want it updated to. What if your users want to contribute to the repository? Not all things committed to the repo have to be relevant to ALL users.
1 Like