__readFile vs. builtins.readFile

That is exaclty the answer. To be complete, builtins (aka. primops) are either considered toplevel and directly available in the global environment, or hidden away with these two underscores. But all builtins are available unprefixed under the builtins variable.

That being said, the prefixed version is seldom used. It may be worth to switch to the builtins.xxx version or import all of them with with builtins;.

And there are more fun facts. builtins.builtins is the only builtin that has no __builtins toplevel counterpart. And builtins.builtins is builtins itself, tying the knot and making builtins.builtins.builtins.readFile a valid builtin. Nix has some quirky loopholes :slight_smile: .

3 Likes