Skip to content

nixos/testing: Add onVMHost attribute to all tests #423276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

roberth
Copy link
Member

@roberth roberth commented Jul 7, 2025

The interaction between pkg.override* and alternate VM hosts does not work.
Concretely, if I'm using Darwin, and I'm developing a patch to a linux package, I'd want to do (pkg.overrideAttrs someFunction).tests, but this does not work, because that will (have to) use the Linux version of the package, whereas we've added our patch (in someFunction) to a Darwin instantiation of the package.
The test framework can compensate for this.

Instead, with this PR, you could override the Linux package, and then build something like (pkg.overrideAttrs someFunction).tests.nixos.onVMHost.aarch64-darwin (where pkg is for Linux).

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/)
  • Nixpkgs 25.11 Release Notes (or backporting 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 25.05 NixOS Release notes)
    • (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, pkgs/README.md, maintainers/README.md and other contributing documentation in corresponding paths.

Add a 👍 reaction to pull requests you find important.

@roberth roberth added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: portability General portability concerns, not specific to cross-compilation or a specific platform 6.topic: testing Tooling for automated testing of packages and modules 6.topic: developer experience nixpkgs development workflow labels Jul 7, 2025
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 9.needs: reviewer This PR currently has no reviewers requested and needs attention. labels Jul 7, 2025
roberth added a commit to roberth/nixpkgs that referenced this pull request Jul 7, 2025
This is useful for repeated ad hoc usage of a package set, as in
NixOS#423276
@wolfgangwalther
Copy link
Contributor

I'm thinking about how to use this while developing for linux from darwin. Am I going to think about anything "cross" or am I thinking "native linux" instead? What I'm after is: Could onVMHost be misleading, depending on context? I understand "Host" to be the host-vs-guest for the VM - but there is also a Build/Host/Target "Host".

and then build something like (pkg.overrideAttrs someFunction).tests.nixos.onVMHost.aarch64-darwin (where pkg is for Linux).

Also I wonder how this "is for linux" comes into play. How would this look like in practice, aka a full call? Just to get an idea of how confusing that might be.

@roberth
Copy link
Member Author

roberth commented Jul 7, 2025

Also I wonder how this "is for linux" comes into play.

Complete example:

nix build .#legacyPackages.aarch64-linux.podman.tests.oci-containers-podman.onVMHost.aarch64-darwin

Am I going to think about anything "cross"

No. "VM Host" is one term here, and it's the same "host" as in hostPkgs. Not great, but no idea what else to call it, and changing hostPkgs would be a project, but I'm open to suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: developer experience nixpkgs development workflow 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: portability General portability concerns, not specific to cross-compilation or a specific platform 6.topic: testing Tooling for automated testing of packages and modules 9.needs: reviewer This PR currently has no reviewers requested and needs attention. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants