Questions about `inputs.nixpkgs`

Kinda confused n00b here, are you saying that if I have a flake with

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
    # etc
  };
  # etc
} 

then it should be changed to read instead

    nixpkgs.url = "https://channels.nixos.org/nixos-25.05/nixexprs.tar.xz";

Or should it be something else? And this is specific to nixpkgs, not any other flake input?

1 Like

Yes and yes. The reasoning why is described above.

I will say that I’ve used the direct github one and I’ve never had temporal cache misses or downtime problems. I also make extensive use of that particular input style by changing it to check a specific revision or PR, so it’s not necessarily always the right choice to switch it.

3 Likes

And you don’t care for the command-not-found database to the point that you forget it even exists, which y’know, fair enough, definitely more of a newbie-friendly feature :wink:

2 Likes

@TLATER , do channel tarbal inputs subsume the utility of something like this too?!

As in, channel tarbals include an uptodate nix-index-database, so no need to remember to either rebuild the database locally or update from another external cache?

1 Like

That’s my understanding, though I have to admit I have not tested this. The tarballs should include the database (that’s where non-flake configs get it from), I don’t know if it’s hooked up correctly by default if you’re using a flake though.

It’s also not nix-index, but the built-in command-not-found. I think nix-index has some side-grades, but AIUI most people using it just use it as a command-not-found replacement for flake-based setups.

1 Like

I just switched over to the tarball based nixpkgs input for a flake after seeing this thread, just to see what the experience is like.

I can confirm that command-not-found seems not be wired up correctly (or even enabled) by default, but it is not terribly complex to wire it up as needed, I have done it here:

And one must wire it up to your shell ( this may be done by default for shells other than nushell, I have not checked.).

It may be done for nushell as seen here:

2 Likes

That’s definitely useful if you only use cnf, and maybe you can even PR this to nixpkgs?
But as someone who uses nix-locate manually, I still find nix-index-database more useful. (I also find cnf to be a bit slow and inconvenient, so I wrote a wrapper around nix-locate to run arbitrary binaries.)

2 Likes

I know this is starting to get off-topic, but can someone sums-up the differences between command-not-found, nix-index, and nix-locate ?

3 Likes

If nom can provide the information it does, nix itself should also be able to calculate the number of revisions.

for i in ${f[@]}; do jq '[.. | objects | paths | select(last == "revCount") | join(".")]' $i 2>/dev/null; done | grep -v '\[\]'

it depends on the use case, but you should probably pin the inputs. a lot of users mentioned third party tarballs/blobs, but semantic versioning tracks that, even if the revCount seems arbitrary.

You missed part of the comment:

Since you don’t have that, you can’t make that computation. It’s metadata, yes, but it doesn’t give you anything you don’t get from a commit hash because semver is meaningless in nixpkgs.

Can / Should this be fixed upstream?

I’d say so, i gave it a quick stab but gave up when I noticed that the nixpkgs input url is no longer exposed stringly in the module system, so you’d have to make nontrivial changes to figure out if the tarball is used.

2 Likes

Just had a look myself, I had a vague recollection that some similar logic is used in nix.nixPath , but apparently it was decided to be too challenging to find the nixpkgs input url there too.

As @TLATER said, it seems this is not trivially possible.

NixOS 25.11 : Release Notes - Backward Incompatibilities :

    • command-not-found package is now disabled by default; it works only for nix-channels based systems, and requires setup for it to work.