Flakes: alias nixpkgs as N

While I love flakes, they’re a bit tedious to write when using nixpkgs. So I added it as N:

$ nix registry add N flake:nixpkgs

and now I can do

$ nix search N s3
$ nix shell N#s3cmd

Since it points to the default flake managed by the registry, everything is cached as normally.

A tiny trick but I thought I’d share.


Nice, how can we verify that really no duplicated data is created? Your reasoning makes sense to me, but would be good to verify anyway

Hmm, shell a package from N and then from nixpkgs and see if it downloads anything? They have to be the same reference though - I see that the default nixpkgs is nixpkgs-unstable not nixos-unstable (I changed it above now).

I just realized I could just use flake:nixpkgs as the target and that works :slight_smile:

yeah, you can use it like nix shell nixpkgs#s3cmd or nix shell flake:nixpkgs#s3cmd. I assumed your post was about renaming nixpkgs to something shorter to save some keystrokes haha

No, it is, see original post now. I was pointing N to github:NixOS/nixpkgs/nixpkgs-unstable and then realized I can just point N to flake:nixpkgs and it works fine!

Just saw your edit :+1:

I’m doing the same thing in my NixOS configuration:

  nix = {
    registry = {
      n.flake = nixpkgs;

where nixpkgs is the “nixpkgs” of NixOS instance.

Hosted by Flying Circus.