Skip to content

New diagnostics infra#15326

Merged
Ericson2314 merged 1 commit intoNixOS:masterfrom
obsidiansystems:no-abs-paths-in-eval
Feb 26, 2026
Merged

New diagnostics infra#15326
Ericson2314 merged 1 commit intoNixOS:masterfrom
obsidiansystems:no-abs-paths-in-eval

Conversation

@Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented Feb 23, 2026

Motivation

  • Convert no-url-literals from experimental feature to Diagnose setting

    Replace Xp::NoUrlLiterals with a new lint-url-literals setting that accepts ignore, warn, or fatal. This provides more flexibility than the binary experimental feature.

  • Convert warn-short-path-literals to use new lint infra

    We now have lint-short-path-literals = ignore | warn | fatal instead.

Context

Fix #10048
Progress on #10281


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@github-actions github-actions bot added new-cli Relating to the "nix" command with-tests Issues related to testing. PRs with tests have some priority labels Feb 23, 2026
@Ericson2314 Ericson2314 force-pushed the no-abs-paths-in-eval branch 2 times, most recently from bca0e3d to 56a03e9 Compare February 24, 2026 17:32
@Ericson2314 Ericson2314 marked this pull request as ready for review February 24, 2026 17:33
false,
"warn-short-path-literals",
LintMode::allow,
"short-path-literals",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this too ambiguous of an option name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added lint- to both

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a stabilization 🎉

My understanding here:

  • this check works
  • it's something we can keep maintaining
  • neither we nor users have felt a need to make this opt-out, but could still be considered

Needs release note.

Should this experimental feature be kept around just to affect the option default? Maybe not because unlike a Nix-based configuration manager, the settings/flags system is tricky and hard to reason about.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something actionable beyond "warning: unknown experimental feature 'no-url-literals'" would be nice

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improved the warning and added the release note

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could, but does not implement the command line options proposed and approved in

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to drop from "Fixes #" or implement

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made it "progress on"

@Ericson2314 Ericson2314 changed the title EvalSettings Warning infra, and some uses cases New diagnostics infra Feb 24, 2026
@Ericson2314 Ericson2314 force-pushed the no-abs-paths-in-eval branch 2 times, most recently from 1c47b3c to 929f50d Compare February 24, 2026 19:43
logWarning(mkInfo());
return;
case Diagnose::Fatal:
throw ParseError(mkInfo());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like harding ParseError here isn't exactly correct. Maybe it should be the callback the decides which error type to throw?

Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideas. See comments.
Also would be nice to have compiler-style flag syntax from the start.
Other than that, lgtm.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can pass options in the lang tests as well. These tests could perhaps be migrated. Characterisation tests give a more detailed coverage of the error reports and nicer DX.

/**
* Treat the feature as a fatal error.
*/
Fatal,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good rename!
We could add Error and a diagnostic state later.
class DiagnosticState { vector<Error>; warn(Error &&); saveError(Error &&); }
or
class DiagnosticState { bool mustThrow; }
and
throwingDiagnosticErrors :: (DiagnosticState -> IO r) -> IO r

Copy link
Member Author

@Ericson2314 Ericson2314 Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed we should collect all fatal errors and then throw. But best saved for later.

@Ericson2314 Ericson2314 force-pushed the no-abs-paths-in-eval branch 2 times, most recently from 17bcefd to 739eee6 Compare February 25, 2026 21:43
.msg = HintFmt("URL literals are disabled"),
diagnose(state->settings.urlLiterals, [&]() -> std::optional<ParseError> {
return ParseError({
.msg = HintFmt("URL literal '%s' is deprecated", std::string_view($1.p, $1.l)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like my earlier comment, this raises the question: which URL literals are allowed?
Instead it should say these independent things:

  • URL literals are disallowed / discouraged (depending on warn/fatal)
  • Here it is
  • Use a string literal instead


source common.sh

clearStoreIfPossible
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please look into this:

  1. Removed test cases not fully covered by new lang tests

no-url-literals.sh went from 7 tests to 4:

  • Old Test 1 (default: unquoted URLs accepted) — REMOVED, not replaced. No new test verifies that lint-url-literals defaults to ignore and URLs work without flags.
  • Old Test 6 (CLI flag override: --extra-experimental-features works even with empty NIX_CONFIG) — REMOVED, not replaced.
  • Old Test 7 (--raw evaluation correctness for quoted URLs) — REMOVED. Partially covered by the new eval-okay-url-literal-warn.exp lang test, but that tests warn mode, not fatal mode with quoted URLs.

short-path-literals.sh went from 11 tests to 10 (8 old + 3 new):

  • Old Test 3 (multiple path patterns: foo/bar, a/b/c/d) — REMOVED. Only test/subdir is tested now. Reduces variation coverage.
  • Old Test 7 (position check: at «string»:1:1:) — REMOVED. Covered by the .err.exp lang tests.
  • Old Test 8 (evaluation correctness: result equals $PWD/test/subdir) — REMOVED. Covered by eval-okay-short-path-literal-warn.exp.

@Ericson2314 Ericson2314 force-pushed the no-abs-paths-in-eval branch 3 times, most recently from f9f6c4e to 0f95928 Compare February 25, 2026 22:21
- Convert `no-url-literals` from experimental feature to `Diagnose`
  setting

  Replace `Xp::NoUrlLiterals` with a new `lint-url-literals` setting
  that accepts `ignore`, `warn`, or `fatal`. This provides more
  flexibility than the binary experimental feature.

- Convert `warn-short-path-literals` to use new lint infra

  We now have `lint-short-path-literals = ignore | warn | fatal`
  instead.

- Convert some of the tests to lang tests

Fix NixOS#10048
Progress on NixOS#10281
@Ericson2314 Ericson2314 added this pull request to the merge queue Feb 25, 2026
Merged via the queue into NixOS:master with commit 89a4412 Feb 26, 2026
15 checks passed
@Ericson2314 Ericson2314 deleted the no-abs-paths-in-eval branch February 26, 2026 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation new-cli Relating to the "nix" command with-tests Issues related to testing. PRs with tests have some priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove the no-url-literals experimental feature

3 participants