Skip to content

Add page size system features#12446

Open
RossComputerGuy wants to merge 4 commits into
NixOS:masterfrom
RossComputerGuy:feat/page-size
Open

Add page size system features#12446
RossComputerGuy wants to merge 4 commits into
NixOS:masterfrom
RossComputerGuy:feat/page-size

Conversation

@RossComputerGuy
Copy link
Copy Markdown
Member

Motivation

Fixes #12426

Context

Prevents issues like NixOS/nixpkgs#348660 from occurring by adding system features which describe the page size. This has the added benefit of systems with multiple builders of utilizing only compatible page sizes.

Testing this PR involves building this PR and running Nix to build any derivation inside this branch of nixpkgs: https://github.com/RossComputerGuy/nixpkgs/tree/feat/page-size

It should not fail with this error:

error: a 'aarch64-linux' with features {pages-16k, pages-32k, pages-4k, pages-64k, pages-8k} is required to build '/nix/store/njf0b0lzfs9gdyylpdyb8gg6s9x0kq35-bootstrap-stage0-glibc-bootstrapFiles.drv', but I am a 'aarch64-linux' with features {benchmark, big-parallel, gccarch-armv8-a, kvm, nixos-test}

Add 👍 to pull requests you find important.

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

@RossComputerGuy RossComputerGuy marked this pull request as draft February 11, 2025 07:17
@github-actions github-actions Bot added the with-tests Issues related to testing. PRs with tests have some priority label Feb 14, 2025
@RossComputerGuy RossComputerGuy marked this pull request as ready for review February 14, 2025 20:40
Copy link
Copy Markdown
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.

This might lead to a mandatoryRejectedSystemFeatures option and machine parameter, or that could be over-engineered.


- [`rejectSystemFeatures`]{#adv-attr-rejectSystemFeatures}\

If a derivation has the `rejectSystemFeatures` attribute, then Nix will only build it on a machine that does not has the corresponding features set in its [`system-features` configuration](@docroot@/command-ref/conf-file.md#conf-system-features).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
If a derivation has the `rejectSystemFeatures` attribute, then Nix will only build it on a machine that does not has the corresponding features set in its [`system-features` configuration](@docroot@/command-ref/conf-file.md#conf-system-features).
If a derivation has the `rejectSystemFeatures` attribute, then Nix will only build it on a machine that does not have the corresponding features set in its [`system-features` configuration](@docroot@/command-ref/conf-file.md#conf-system-features).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for catching that, it's fixed now.

rejectSystemFeatures = [ "pages-16k" ];
```

ensures that the derivation can only be built on a machine which do not have the `pages-16k` feature.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
ensures that the derivation can only be built on a machine which do not have the `pages-16k` feature.
ensures that the derivation can only be built on a machine which does not have the `pages-16k` feature.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

/* Right platform? */
if (!parsedDrv->canBuildLocally(worker.store))
throw Error("a '%s' with features {%s} is required to build '%s', but I am a '%s' with features {%s}",
throw Error("a '%s' with features {%s} & not {%s} is required to build '%s', but I am a '%s' with features {%s}",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not pretty when empty, but that was already the case for required ones.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I'm curious how we should handle things when it's empty.

echo "$output" | grepQuiet builder-build-remote-input-3.sh
unset output

# Ensure that input4 was built on store4 due to the required feature.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This isn't obvious from the code below. Could you add assertions that simply check what you're saying here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I tried getting a test here which would reject builds in the proper way but I'm not confident with the testing framework so I might need guidance.

@roberth
Copy link
Copy Markdown
Member

roberth commented Feb 19, 2025

It seems that #12292 introduced a conflict.
@Ericson2314 what is the status of #12410?

@RossComputerGuy RossComputerGuy force-pushed the feat/page-size branch 2 times, most recently from 75a730b to 0bcf588 Compare February 19, 2025 14:59
Copy link
Copy Markdown
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

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

I'm late to this, but I don't think "reject system features" is a good framing of this. I think it's better to keep "positive" rather than "negative reasoning.

For the case of page size, there is set if page sizes which are allowed, and the system is required to have its page sizes be in the set.

@RossComputerGuy
Copy link
Copy Markdown
Member Author

RossComputerGuy commented Mar 18, 2025

The problem I had with requiredSystemFeatures and the page size was that it applies to all derivations. This would make ranges difficult since then it'll be an & and not || like it should be since the ranges will be different. Reject system features would reject a build when the builder has a specific page size which simplified how this would apply.

A good example of this is if the minimum page size is 16 but a derivation supports the minimum of 4k, the builder would not have the 4k page size feature and would fail saying that it doesn't have the feature.

@Ericson2314
Copy link
Copy Markdown
Member

Yes, it is better to add "or" than "not".

@RossComputerGuy
Copy link
Copy Markdown
Member Author

The problem is how to do an || with system features, the not is much simpler imo.

@Ericson2314
Copy link
Copy Markdown
Member

@RossComputerGuy I don't want to delay this too much, but with structured attrs that gets much easier.

@tomberek tomberek moved this from To triage to ⚖ To discuss in Nix team Jun 4, 2025
@nixos-discourse
Copy link
Copy Markdown

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2025-05-04-nix-team-meeting-minutes-230/65206/1

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

Labels

documentation with-tests Issues related to testing. PRs with tests have some priority

Projects

Status: ⚖ To discuss

Development

Successfully merging this pull request may close these issues.

Add a page size system feature

6 participants