8000 Settings: route each scope to the Nix door that accepts it · Issue #35 · nixidae/nixidae · GitHub
[go: up one dir, main page]

Skip to content

Settings: route each scope to the Nix door that accepts it #35

Closed

Description

@Lillecarl

Session(settings=NixSettings(...)) raises for every field outside the global
scope. This is the headline configuration object, and four of its five scopes
do not work.

Evidence

NixSettings inherits five scopes (nanopynix/src/nanopynix/settings.py:597).
to_worker_settings() renders every set field of all five into one flat
mapping. Session.__init__ passes that mapping to
NixCore.initialize, which applies each entry with
nanopynix_util.set_setting (_core/_nix_core.py:92). That binding is
nix::globalConfig.set() (nanopynix-bindings/src/nix_util.cpp:38).

Measured with one process for each case, rpc engine, Nix 2.34:

max_jobs             OK
trusted              FAIL  RuntimeError: unknown setting: trusted
pure_eval            FAIL  unknown setting: pure-eval
allowed_uris         FAIL  unknown setting: allowed-uris
tarball_ttl          FAIL  unknown setting: tarball-ttl
accept_flake_config  FAIL  unknown setting: accept-flake-config
priority             FAIL  unknown setting: priority
want_mass_query      FAIL  unknown setting: want-mass-query
path_info_cache_size FAIL  unknown setting: path-info-cache-size
max_call_depth       FAIL  unknown setting: max-call-depth
restrict_eval        FAIL  unknown setting: restrict-eval
warn_dirty           FAIL  unknown setting: warn-dirty

The inproc engine fails in the same way.

The cause is not an ordering mistake. globalConfig and the three other
registries are disjoint in every supported Nix version:

global count 85
eval  n global: []
fetch n global: []
flake n global: []
store-default names in global: []

set_setting("pure-eval", ...) fails in the same way before and after
init_libexpr(), so moving the call does not help.

The store half of the promise works: NixStoreDefaults.from_settings feeds
resolve_store_spec, which writes the store settings into the store URI. The
eval, fetch and flake halves are not implemented at all.

Why no test caught it

Every NixSettings(...) in tests/ and in docs/examples/ names global-scope
fields only. The one test that uses eval settings passes them to
session.eval(...), which is the working path.

Scope

  • Add for_scope(scope) to NixConfigModel, which returns the scope model.
    Build it the way NixStoreDefaults.from_settings already does.
  • Session.__init__ sends only
    for_scope(NixGlobalSettings).to_worker_settings() to initialize.
  • Keep the other four scopes as session defaults, for Settings: merge session-level eval, fetch and flake defaults #36.
  • Delete the comment in check_settings_model_drift
    (settings.py:723-730) which says globalConfig aggregates the evaluator,
    fetcher and flake settings. The measurement above disproves it. Delete the
    filtering step that the comment justifies, because that step removes
    nothing.

Files

nanopynix/src/nanopynix/settings.py, inproc/_impl.py,
rpc/client/session.py, _core/_nix_core.py,
docs/nanopynix/api/settings.md.

Risk

Medium. This touches the path that every session opens through. The drift
checks and the settings test group bound the risk.

Acceptance criteria

Session(settings=NixSettings(<field>)) opens for one field from each of the
five scopes, on both engines, on both store backends.

Tests

Add a parametrised test to tests/nanopynix/test_config_flow.py, one case for
each scope. Assert the value through the door that owns it: the global scope
through session.settings(), the store scope through
store.uri(with_params=True), the eval and fetch scopes through observable
behaviour, and the flake scope through a flake operation.

Compatibility

This breaks nothing. A global-scope field still reaches globalConfig. The
four other scopes move from raising to working.

Alternative, rejected

Session.__init__ could reject a non-global field with a clear message. That
is smaller and honest, but it removes the catch-all the design chose, and it
leaves a caller with no way to set a session-wide pure_eval.

Finding F1 of CODE_IMPROVEMENT_PLAN.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    source: nanopynix

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0