Skip to content

darwin: installBinaryPackage Add install darwin binary tests#441396

Draft
dwt wants to merge 6 commits intoNixOS:masterfrom
dwt:add-install-darwin-binary-tests
Draft

darwin: installBinaryPackage Add install darwin binary tests#441396
dwt wants to merge 6 commits intoNixOS:masterfrom
dwt:add-install-darwin-binary-tests

Conversation

@dwt
Copy link
Contributor

@dwt dwt commented Sep 9, 2025

This pull request starts adding some test cases for darwin.installBinaryPackage to understand how it works, and ensure we can keep it working correctly indefinitely.

This is very much a work in progress right now, so please review the tests and the idea instead of the commit structure for now. I also suspect that it may be possible to write nix unit tests to check that an installed package has a specific SRI hash, but I haven't yet found out a way to do so. Still this would allow us to execute the tests locally on macOS instead of trying to get them to work on linux which would be a great simplification.

This is meant to build upon #293498 so best review them in tandem.

Note: This pull request will be rebased aggressively onto #293498 as we work on this feature.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Sep 9, 2025
@nixpkgs-ci nixpkgs-ci 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. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS labels Sep 9, 2025
Copy link
Contributor

@acid-bong acid-bong left a comment

Choose a reason for hiding this comment

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

Please, read the contributing docs on title conventions (they're the same for both commits and PRs). They must be formatted as SCOPE: CHANGES, where SCOPE is a name of a package or nixos/MODULENAME

@dwt dwt changed the title Add install darwin binary tests darwin: installBinaryPackage Add install darwin binary tests Sep 9, 2025
@dwt
Copy link
Contributor Author

dwt commented Sep 9, 2025

Please, read the contributing docs on title conventions (they're the same for both commits and PRs). They must be formatted as SCOPE: CHANGES, where SCOPE is a name of a package or nixos/MODULENAME

Is this better?

@dwt dwt force-pushed the add-install-darwin-binary-tests branch 5 times, most recently from 55fddbf to 3f0977a Compare September 9, 2025 19:54
@afh afh added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 14, 2025
@afh
Copy link
Member

afh commented Sep 14, 2025

This is amazing, @dwt, mind resolving the merge conflicts? I'd be happy to cherry-pick your additional changes into #293498

@dwt
Copy link
Contributor Author

dwt commented Sep 15, 2025

@afh I am thinking about exploring rewriting these as $package.passthru.tests. It seems to me from the docs that runCommand might actually be enough to run this test without having to resort to virtual machines (as all it is doing is running the installer and checking a checksum. That would enable building the tests only on darwin, which is where they belong anyway and should remove all unforeseen problems with unpacking something that can only be unpacked on darwin (because of dependencies).

@dwt dwt force-pushed the add-install-darwin-binary-tests branch from 3f0977a to 2178195 Compare September 17, 2025 20:37
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 17, 2025
@dwt
Copy link
Contributor Author

dwt commented Sep 17, 2025

@afh what do you think about this? As far as I can tell this is a much simpler way to test this, builds natively on darwin and doesn't require any linux VMs to execute.

Also the zip based test fails, as far as I can tell because the sourceRoot cannot be reset to '' (empty string) from the derivation.

What do you think? Perhaps with darwin.fetchDMG we may be able to simplify this even more?

@nixpkgs-ci nixpkgs-ci bot removed the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Sep 17, 2025
@dwt dwt force-pushed the add-install-darwin-binary-tests branch 2 times, most recently from 5f123e5 to 3d68797 Compare September 22, 2025 19:42
@afh
Copy link
Member

afh commented Sep 23, 2025

@dwt #293498 now contains changes—I've kept them in a separate commit for the time being—to support use of finalAttrs with darwin.installBinaryPackage.

While testing these changes with the helpful tests added in this PR the tests failed with:

error: the value being indexed in the selection path 'darwin.installBinaryPackage.tests.pkg' at 'darwin.installBinaryPackage' should be a set but is a function: «lambda @ ~Developer/nixpkgs/lib/customisation.nix:845:9»

Happy to take a look at this together…

@dwt dwt force-pushed the add-install-darwin-binary-tests branch from 3d68797 to 641eec5 Compare September 24, 2025 20:54
@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Nov 1, 2025
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 6.topic: darwin Running or building packages on Darwin 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants