Skip to content

nixosTests: pass thru pkgs when available - #331873

Merged
roberth merged 1 commit into
NixOS:masterfrom
ExpidusOS:feat/nixos-tests-pkgs
Apr 26, 2025
Merged

roberth merged 1 commit into
NixOS:masterfrom
ExpidusOS:feat/nixos-tests-pkgs

Conversation

@RossComputerGuy

Copy link
Copy Markdown
Member

Description of changes

Passes pkgs through to each eval-config.nix import to ensure the tests contains the supplied pkgs. This allows for being able to test cross compilation, musl, LLVM, static nixpkgs, etc.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions Bot added the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Aug 3, 2024
@ofborg ofborg Bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Aug 3, 2024
@tomberek
tomberek requested a review from infinisil August 3, 2024 02:16

@tomberek tomberek left a comment

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.

@infinisil please review as this changes how pkgs is injected into module evaluation

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one person. label Aug 3, 2024
@github-actions github-actions Bot added the 6.topic: testing Tooling for automated testing of packages and modules label Aug 4, 2024
RossComputerGuy added a commit to RossComputerGuy/nixpkgs-llvm-ws that referenced this pull request Aug 4, 2024
@Aleksanaa

Copy link
Copy Markdown
Member

Thank you on behalf of @dramforever and PLCT lab!

@ofborg ofborg Bot added 8.has: clean-up This PR removes packages or removes other cruft 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Aug 4, 2024
@wegank wegank removed the 12.approvals: 1 This PR was reviewed and approved by one person. label Aug 4, 2024

@infinisil infinisil left a comment •

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.

I have a minor suggestion, but this looks good to me, though I don't fully understand this fully

This allows for being able to test cross compilation, musl, LLVM, static nixpkgs, etc.

Could you give an example of what's now possible with this? And couldn't one set nixpkgs.pkgs to also achieve this?

Oh and ping @roberth

Comment thread nixos/lib/testing/nodes.nix Resolved
@RossComputerGuy

Copy link
Copy Markdown
Member Author

Could you give an example of what's now possible with this?

You can now try building all tests in pkgsLLVM.nixosTests.boot and pkgsLLVM.nixosTests.boot-stage. Before, the NixOS config would import pkgs itself since that wasn't passed through. Similar pkgs* sets in nixpkgs can try building these tests. However, this does not guarantee that these tests will build but at least this doesn't break anything existing. Eventually I will be fixing some of the tests for pkgsLLVM.

@infinisil infinisil left a comment

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.

Neat, great work! 🚀

@RossComputerGuy RossComputerGuy added the 12.approvals: 2 This PR was reviewed and approved by two persons. label Aug 7, 2024

@roberth roberth left a comment

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.

Unfortunately this stuff has a long history.

OT: I think there's still opportunity to simplify things on the NixOS "core" side.
Perhaps the normal nixpkgs.nix module could integrate the "read only" functionality after system/crossSystem/localSystem are deprecated.
Right now that's the added complexity of those legacy parameters makes that rather difficult, not impossible, but difficult and hard to review.

Comment thread nixos/tests/boot.nix Outdated
Comment on lines 45 to 68

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.

  • pkgs is a redundant argument we might want to get rid of; see comment in eval-config.nix - use the option instead
  • It'd be good to make sure we're not accidentally ignoring any of the nixpkgs.* settings by making them read-only.
  • system is also redundant, because it's only needed for creating a pkgs, which we already have.
Suggested change
inherit system pkgs;
modules = [
modules = [
{ nixpkgs.pkgs = pkgs; }
../modules/misc/nixpkgs/read-only.nix

(Same applies to the other eval-config.nix calls)

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.

Alright, I've made that change

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.

Removing system causes this:

       error: The option `nixpkgs.system' does not exist. Definition values:
       - In `/nix/store/fqjbkkwvb4h14bb4vl9pb28pja11bpcv-source/nixos/lib/eval-config.nix':
           {
             _type = "override";
             content = "aarch64-linux";
             priority = 1000;
           }

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.

I guess that could be prevented by passing system = null; to eval-config.nix, but at that point we're adding too much boilerplate in my opinion. Let's postpone my proposal for when we have a nice and clean entrypoint. (in nixos/lib/default.nix?)

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, that fixed it.

Comment thread nixos/lib/testing/nodes.nix Resolved
@wegank wegank removed the 12.approvals: 2 This PR was reviewed and approved by two persons. label Aug 10, 2024
@tomberek
tomberek requested a review from roberth August 16, 2024 06:28
Comment thread nixos/lib/testing/nodes.nix Outdated
Comment on lines 163 to 167

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.

Probably my suggestion was wrong. This undoes the optimization for tests that have node.pkgsReadOnly = true;; the opposite of your intent.
I think you can just revert this chunk, ie leave nodes.nix as is.

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.

Alright, reverted.

@RossComputerGuy
RossComputerGuy force-pushed the feat/nixos-tests-pkgs branch 2 times, most recently from 703bfce to 2dd7550 Compare August 16, 2024 16:11

@roberth roberth left a comment

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.

Looks good in principle. What are the attributes to pass to ofborg?

@RossComputerGuy

Copy link
Copy Markdown
Member Author

I'm not sure, I think we can just get away with at least only running the boot tests. The other changes are probably trivial enough that it wouldn't be a concern not to run them.

@wegank wegank added the 12.approvals: 3+ This PR was reviewed and approved by three or more persons. label Oct 29, 2024
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Dec 10, 2024
@github-actions github-actions Bot removed the 6.topic: testing Tooling for automated testing of packages and modules label Apr 25, 2025
@RossComputerGuy

Copy link
Copy Markdown
Member Author

This PR has been rebased, going to spin up the tests and see if this works.

@ofborg ofborg Bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Apr 25, 2025
@github-actions github-actions Bot added 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. and removed 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Apr 25, 2025
@roberth

roberth commented Apr 26, 2025

Copy link
Copy Markdown
Member

✔️

nix-build -A nixosTests.boot.uefiCdrom -A nixosTests.boot.biosUsb
nix-build -A nixosTests.boot.biosNetboot

@roberth
roberth merged commit 0c4525d into NixOS:master Apr 26, 2025
@RossComputerGuy
RossComputerGuy deleted the feat/nixos-tests-pkgs branch April 26, 2025 16:59
@RossComputerGuy

Copy link
Copy Markdown
Member Author

Woops, this broke pure eval. Let's fix it in #404284.

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

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: clean-up This PR removes packages or removes other cruft 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. 12.approvals: 3+ This PR was reviewed and approved by three or more persons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants