Skip to content

meta.problems: move unsupported platform support to meta.problems - #545234

Draft
andir wants to merge 5 commits into
NixOS:masterfrom
tweag:andir/meta-problems-unsupported
Draft

andir wants to merge 5 commits into
NixOS:masterfrom
tweag:andir/meta-problems-unsupported

Conversation

@andir

@andir andir commented Jul 24, 2026

Copy link
Copy Markdown
Member

Things done

This is the initial draft of migrating the meta.platforms checks aka unsupported (platforms) into the new RFC127 style meta.problems.

This is still missing support for

  • proper remediation messages like we used to have them. The way they are currently implemented in problems.nix isn't flexible enough yet. I'll work on that next.
  • it isn't enabled by default (see commit messages)
  • there are no new tests for it yet but I've some locally and will add them once the kinks are ironed out
  • release notes making note of using the matchers facilities to deal with unsupported platform attributes. The current configuration via nixpkgs.config and the environment variables are still supported. We likely need at least one release cycles before we can deprecate them (if we want that).

This PR currently depends on #545182 as the test otherwise show false negatives when ran.

  • Built on platform:
    • x86_64-linux
  • Tested, as applicable:
    • nix-build -A tests.problems
  • NixOS Release Notes
    • Make note in the matchers sections
    • Make a deprecation note on the old behaviour, probably first a builtins.throw warning when they are bing used (as authoritative override), then a failure and then rip them out for good in N+2 releases?
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.
  • Follows the automation/AI policy. No AI was used for this work :)

@andir
andir requested review from MattSturgeon, infinisil and llakala and removed request for infinisil July 24, 2026 13:06
@llakala

llakala commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Performance protector here - diff looks good on a readthrough. Once CI passes, I'm curious how much this will hurt our numbers. Hopefully not much, since we've already paid the toplevel cost of any.

@andir

andir commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

Performance protector here - diff looks good on a readthrough. Once CI passes, I'm curious how much this will hurt our numbers. Hopefully not much, since we've already paid the toplevel cost of any.

Yeah, I think this might not hurt much, if at all. We've already done the exact same checks previously. It is just that the point in the eval when we do it has shifted. Also note that since there isn't a handler defined at all they currently aren't even failing eval in this PR. Likely meaning they are even cheaper currently. We've to enable them for it to carry a cost.

I'm also very much interested in keeping them cheap / making it cheaper to compute. I'll have to carve out some idea to measure the actual impact properly. Eval times are often very noisy in my experience. Perhaps forced thunk counts could be useful as a proxy metric.

@llakala

llakala commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

I've been working on automatically running perf inside our CI to count instructions. The Eval Summary page prints a lot of deterministic stats, but numbers like cpuTime vary a ton, and I'd like to get rid of them. The CI mechanisms already support running perf, I just need to finish adding the logic to our compare script.

@llakala

llakala commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Also, I believe forced thunk counts is nrThunks in the eval summary.

@andir

andir commented Jul 26, 2026

Copy link
Copy Markdown
Member Author

Also, I believe forced thunk counts is nrThunks in the eval summary.

It seems like this is just counting created thunks: https://github.com/NixOS/nix/blob/master/src/libexpr/eval.cc#L974

I've some old hacky patches locally to get some more relevant numbers out of nix. Nothing pretty but perhaps a good starting point.

@infinisil

Copy link
Copy Markdown
Member

Probably good to sync with #533181

andir added 5 commits July 31, 2026 12:05
This allows messages to be generated for a specific condition. For
example we can tell users if a system is unsupported and which ones
are supported. This is required to migrate e.g. the unsupported
platform errors to the new meta.problems system.
This is helpful to make errors depend on the hostPlatform and the
attributes in a package. One famous candidate is the `unsupported`
platforms attribute that needs both the knowledge of the current
nixpkgs hostPlatform and the packages meta.platforms attribute.
This moves the remediation message formatting functions into a
separate file. The benefit is that we can now use this from multiple
locations where similar/the same message must be generated without
duplicating the format. The messages are well understood and if they
are not improving one location should improve all of the cases where
we emit them..

This will play into the `meta.problems` migration for legacy checks as
they can much easier (and more consistently) emit the same (or at least very
similar) message for failures.
This introduces the unsupported meta attribute from the legacy code to
the new meta.problems. For backwards compatibility the environment
variables and nixpkgs.config attributes work as they used to.
Additionally we can now use the matcher infrastructure to enforce the
platform checks.

TODO: add the `unsupported` type to the default configuration so it
fails eval.
This enabled the meta.problems `unsupported` error variant.
@andir
andir force-pushed the andir/meta-problems-unsupported branch from 7811d2c to 7808463 Compare July 31, 2026 10:12
let
hasUnsupportedPlatform' = hasUnsupportedPlatform hostPlatform;
in
attrs: hasUnsupportedPlatform' attrs && !allowUnsupportedSystem;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: if allowUnsupportedSystem is false, we can always avoid checking:

condition =
  config:
  if config.allowUnsupportedSystem || envAllowUnsupportedSystem then
    _: _: false
  else
    hasUnsupportedPlatform

@andir

andir commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

did some initial measurments on thunk counts. It seems like for firefox this currently requires ~0.3% more thunk generation:
image

I've played with some line-level thunk profiling counters and here are the current results:

https://s.rammhold.de/nix-thunk-profile-baseline/
https://s.rammhold.de/nix-thunk-profile-new/

This currently tanks the Nix eval wallclock performance but should give reasonable numbers. Needs more testing tho.. Very first draft.

andir added a commit to andir/nixpkgs that referenced this pull request Aug 28, 2026
This is moving the remediation messagesd into their dedicated file
where all their (internal) utiltiy functions aren't cluttering the
check-meta implementation and the remediation messages could
potentially be emitted from other places in nixpkgs while keeping the
styling the same.

The driving motivation behind this is moving more checks into
meta.problems and there we should very likely emit the messages in the
same flavour users might be used to (either visually, by script or the
wording).

This was previously proposed as part of NixOS#545234 but is worthwhile on
its own IMO.
zh4ngx pushed a commit to zh4ngx/nixpkgs that referenced this pull request Aug 30, 2026
This is moving the remediation messagesd into their dedicated file
where all their (internal) utiltiy functions aren't cluttering the
check-meta implementation and the remediation messages could
potentially be emitted from other places in nixpkgs while keeping the
styling the same.

The driving motivation behind this is moving more checks into
meta.problems and there we should very likely emit the messages in the
same flavour users might be used to (either visually, by script or the
wording).

This was previously proposed as part of NixOS#545234 but is worthwhile on
its own IMO.
@nixpkgs-ci nixpkgs-ci Bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants