Skip to content

libnixf: incremental eval & type inference system #482

Open
@inclyc

Description

Design Review

Motivation

Evaluation is indeed indispensable in the Nix language.

For example, #480 mentioned if we can provide some auto-completion for custom args:

{ pkgs, root, ... }: # <- provide autocompletions for these args using the expression above

Case 2: #471 mentioned if we can provide completions for "selection"

{pkgs}:
{
  asdf = pkgs.asdf;
}

Previously, nixd performed comprehensive evaluations, gathering insights into the values linked with each Abstract Syntax Tree (AST) node. This method facilitated the provision of language features like completion and diagnostics through real-time evaluations. However, the performance repercussions are significant. Each system-wide configuration evaluation takes several seconds to finalize, and users are obliged to specify the project's evaluation method, which is rather inconvenient.

However, the performance implications of full evaluation can severely hinder on-the-fly editing. So the challenge is:

  • How to incrementally evaluate the code? (In less than ms?)
  • How to discover the target automatically?

Ideas

"Incremental" processes invariably entail immutability. Hence, I've been pondering the prospect of introducing immutability to certain segments of the evaluation process. For instance, we could maintain the immutability of the evaluation results for all Nixpkgs. Perhaps the optimal solution lies in devising an evaluation system focused on individual files, while deferring resolution on external immutable values. But the question remains: how can we achieve this?

Value resolution regarding nix language

So what is the resolution then...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions