Access lib in flake before pkgs is available

I want to access lib in a flake, before pkgs exists [because I want a more fine-grained, per-package version of this, which uses lib].

I’m aware of two ways of getting lib:

  1. as an attribute of pkgs
  2. as a NixOS module system (?) parameter

neither of which are available in this context.

Can I get my hands on lib here? or will I need to roll my own version of the function I need?

Edit: Though in this particular case, lib.getName pkg seems to be equivalent to pkg.pname? In which case lib wouldn’t be necessary to solve this particular problem, but it would still be interesting to know whether it’s possible to get lib here.

In a flake, you can access it using nixpkgs.lib (assuming you have an input named nixpkgs).