Repository navigation
Description
What is missing
The detail pane of pynix search draws an option's name, type, description
and declarations. It draws no default and no example, which are the two
fields a reader most often wants after the description.
Why they are absent, and what that reason really covers
pynix/_options.py excludes them on purpose, and the module docstring gives
two reasons:
- The walk returns one Nix list, forced in one JSON pass. A single
option whose default cannot evaluate aborts the whole fetch of all 24 941. - A
tryEval/deepSeqguard does not help, becausetryEval"only
prevents errors created bythroworassert", and an
"attribute X missing" failure is a builtin-generated error that it does
not catch.
Both are true, and both are about the bulk pass and about catching
inside Nix. Neither reaches a force of one option at render time, caught
on the Python side.
The measurement
One option at a time, through the bindings:
| option | default |
outcome | cost |
|---|---|---|---|
default = false; example = true; |
forced | False, and True |
0.7 ms |
default = throw "nope"; |
forced | caught as ThrownError |
-- |
default = ({}).absent; |
forced | caught as EvalError |
-- |
default = { a = 1; b = [ 1 2 ]; }; |
forced | {'a': 1, 'b': [1, 2]} |
0.6 ms |
The third row is exactly the failure that tryEval cannot catch. Across the
binding boundary it is an ordinary Python exception. The eval session stays
usable after both failures, verified by reading a good default afterwards.
So the field can be forced per option, at the moment the pane draws it, and
an option that cannot answer costs its own pane a line and nothing else.
The blocker
No evaluator is alive while the interface runs. _impl/search.py opens
one inside async with eval_session(...) at line 309 and closes it before
browse() at line 257. On a warm cache _build_index never runs, so no
session opens at all -- which is the whole point of the cache.
The decision this needs
Rendering a default needs a session that outlives the index build. Two
shapes, and the difference is what a reader waits for:
- Open it when the interface opens. Simple. It pays the evaluation on
every search, including the warm ones the cache exists to make instant.
Measured on one NixOS configuration: about 5 s. - Open it when a pane first needs a default. The first selection that
wants one pays; every search that only reads names and descriptions stays
instant. It needs the session to be built inside the interface, under a
budget, and a pane that says it is still resolving.
A live evaluator also answers a second want: showing the configured value
of the selected option, not only its declaration.
Acceptance
- The pane draws
defaultandexamplewhen the option declares them. - An option whose default cannot evaluate says so, and costs no other
option anything. - A search that reads only names and descriptions is no slower than now.
- Tests cover the plain case, the
throwcase and the
attribute-missing case.
Activity
feat(pynix): let a concrete path match the option it instantiates
fix(search): make the detail pane really scroll
feat(pynix): let a concrete path match the option it instantiates
feat(search): render an option's default and example in the detail pane
fix(search): make the detail pane really scroll