My primary intent is to propose a PR to the nix-mode issue #166, completing nix-mode knowledge of available builtins.
At first I thought of using something like
nix eval --expr 'builtins.attrNames builtins'
to produce that list, but I quickly discovered that not all of those names are available in the basic scope of an expression. For example, fromTOML
is there while readFile
is not.
Now that I understand that, probably the current list of builtins known by nix-mode
is nearly complete, but I still like to add missing items, if any.
I tried to dig into the nix
sources but failed to understand by which logic some RegisterPrimOp
item is actually registered in the base scope (say that is available in a simple nix repl
, displayed by hitting TAB on an empty line).
A similar doubt often nags me when I write a nix expression, as obviously I must use builtins.readFile
and not simply readFile
, as I can with fromTOML
: luckily my GNU/Emacs config highlights such errors, thanks to flymake
that behind the scenes uses nix-instantiate --parse
to verify the syntax.
So the questions:
- What is the rationale that drives the selection of directly available builtins names?
- Is there a way to programmatically obtain the builtins names that are available in the base scope?
Thanks in advance!