How to apply an overlay to registry

I’d like to apply an overlay at my nixpkgs registry, but can’t make it work. Is there a way to do this? Until now, I’ve been using nix.registry.nixpkgs.flake = nixpkgs; , nixpkgs being the flake input.
I tried using import nixpkgs { overlays = [ ( \* My overlay *\ ) ]; }, but it throws an error:

error: attribute 'currentSystem' missing

       at /nix/store/wkavyf1xaqkpw8f74wig2h18f3mlr862-source/pkgs/top-level/impure.nix:18:43:

           17|   # (build, in GNU Autotools parlance) platform.
           18|   localSystem ? { system = args.system or builtins.currentSystem; }
             |                                           ^
           19|
(use '--show-trace' to show detailed location information)

It is not possible to apply an overlay to the registry.
Registry expects a derivation/path of some sort which means that the only solution here is to patch nixpkgs

Maybe you will get some inspiration from this: GitHub - gytis-ivaskevicius/flake-utils-plus: Use Nix flakes without any fluff.

  1. It is able to patch nixpkgs
  2. Exposes pkgs with applied overlays which anyone can evaluate. Here is an example:
❯ repl
Welcome to Nix version 2.5pre20211007_844dd90. Type :? for help.

Loading '/nix/store/87c3crz9nsxpi9py3sjd57shla01zqh5-repl.nix'...
Added 15906 variables.

nix-repl> flake.pkgs.x86_64-linux.nixpkgs.fup-repl
«derivation /nix/store/qhh2q0wcax3k9fnbkrhwpj3b1lyl0487-repl.drv»

nix-repl> pkgs.fup-repl
«derivation /nix/store/qhh2q0wcax3k9fnbkrhwpj3b1lyl0487-repl.drv»
2 Likes

I don’t think “it’s not possible” is a satisfactory answer. If that’s the case, the implementation needs to be changed to make it possible, since this would seem to be the common use case. Simple things should be easy, etc.

@felipeqq2 tried import nixpkgs { overlays = [ ( \* My overlay *\ ) ]; } and got error: attribute 'currentSystem' missing. That’s because they didn’t provide a system argument, like import nixpkgs { system = "x86_64-linux"; overlays = [ ( \* My overlay *\ ) ]; }, which would have worked.