Skip to content

Extend nix flake check to support custom attributes #6453

@NobbZ

Description

@NobbZ

Is your feature request related to a problem? Please describe.

When running nix flake check one regularly sees warnings emitted by nix about unknown attributes, or default* moved to something else.

Especially the unknown attributes can be annoying, even more those that evolved into a quasi-standard, like lib (even used by nixpkgs) or homeModules and homeConfigurations.

Describe the solution you'd like

There might be yet another flake output which is not a derivation but instead a function that takes and arbitrary value and returns a list of string or set of string.

I initially wanted to use checks for this, though that is already used for something else. In lack of a better name, I therefore use nixChecks in the following examples.

Once nix flake check encounters an attribute foo it doesn't know how to check, it calls self.nixChecks.foo self.foo.

nixChecks can then use arbitrary nix functions to verify the value of foo to match the requirements and issue informative messages, warnings or errors. It should be avoided to use traceing functions from the nixChecks though it lies in the nature of the checks, that they require at least partial evaluation of the values, and therefore might trigger traceing calls within the value.

A message is either a set with level and message (where level is "info", "warning", or "error".) or alternaively just a string, which is assumed to be the message for a warning then.

Whenever at least one error got emitted, the exit code of nix flake check should be non-zero.

Describe alternatives you've considered

External programs that would check validity of custom attributes while continue to ignore warnings issued by nix flake check, or not run it at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    UXThe way in which users interact with Nix. Higher level than UI.
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions