In the snippet below, does callPackage = pkgs.newScope {} refer to the definition of newScope right below?
What throws me off is that this is not a recursive attribute set and pkgs is coming from splice.nix’s header (i.e., lib: pkgs: actuallySplice:). Is this another thing that is possible because of Nix’s lazy evaluation? (As demonstrated in Nix Pills #17 or here.)
The pkgs here is a function argument as you can see at the top of the file. In order to find out what the value of pkgs would be as it’s called, you must figure out where the function declared by this file is called.
A quick grep for splice.nix in Nixpkgs reveals that it’s imported by stage.nix. This file assembles the pkgs set we all know and love which includes things like adding pkgsMusl, pkgsStatic etc. and applying the specified overlays among a few other things. One of those other things is defining callPackage which is handled by splice.nix.
At the import, you can see that it gets called with self (aka. final) and that answers your question: The usage of pkgs in splice.nix is the same as final in an overlay context and newScope is indeed the function defined below.