Skip to content

ci/eval/compare: don't treat renames as rebuilds#431448

Merged
wolfgangwalther merged 1 commit intoNixOS:masterfrom
wolfgangwalther:ci-renamed-rebuilds
Aug 6, 2025
Merged

ci/eval/compare: don't treat renames as rebuilds#431448
wolfgangwalther merged 1 commit intoNixOS:masterfrom
wolfgangwalther:ci-renamed-rebuilds

Conversation

@wolfgangwalther
Copy link
Contributor

@wolfgangwalther wolfgangwalther commented Aug 6, 2025

When a package's attrpath is renamed it is currently treated as a rebuild, even though the outpath already exists and is already cached.

This also happens when adding new names for packagesets that already exist, for example when starting to eval perlPackages in CI, which is just the same as perl540Packages currently. It would also happen when perlPackages is switched from perl540Packages to perl999Packages. Assuming that perl999Packages had already been built before, this doesn't really cause any rebuilds.

Things done

  • Test with removal of perlPackages = {} in release.nix, should result in no rebuilds (only works in my fork, because the comparison changes need to be on the target branch already)
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@wolfgangwalther wolfgangwalther force-pushed the ci-renamed-rebuilds branch 2 times, most recently from 28783b9 to 07015f8 Compare August 6, 2025 13:13
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux: 1001-2500 This PR causes many rebuilds on Linux and should target the staging branches. 10.rebuild-darwin: 1001-2500 This PR causes many rebuilds on Darwin and should most likely target the staging branches. 6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions backport release-25.05 labels Aug 6, 2025
@wolfgangwalther wolfgangwalther force-pushed the ci-renamed-rebuilds branch 3 times, most recently from 47bdb4a to 24efeab Compare August 6, 2025 14:45
@wolfgangwalther wolfgangwalther marked this pull request as ready for review August 6, 2025 14:46
@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. and removed 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux: 1001-2500 This PR causes many rebuilds on Linux and should target the staging branches. 10.rebuild-darwin: 1001-2500 This PR causes many rebuilds on Darwin and should most likely target the staging branches. labels Aug 6, 2025
When a package's attrpath is renamed it is currently treated as a
rebuild, even though the outpath already exists and is already cached.

This also happens when adding new names for packagesets that already
exist, for example when starting to eval `perlPackages` in CI, which is
just the same as `perl540Packages` currently. It would also happen when
`perlPackages` is switched from `perl540Packages` to `perl999Packages`.
Assuming that `perl999Packages` had already been built before, this
doesn't really cause any rebuilds.
Copy link
Contributor

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

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

Nice!

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Aug 6, 2025
Copy link
Contributor

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

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

I suspect there's a load of performance work we could do here, but it likely doesn't matter.

old: new:
let
filterKeys = cond: attrs: lib.attrNames (lib.filterAttrs cond attrs);
oldOutputs = lib.pipe old [
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be computed without respect to the new and hence can be in a let block before the new.

let
  filterKeys = ...;
in
old:
let
  oldOutputs = ...;
in
new:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

filterKeys was before the arguments before. Does any of this make a difference if this diff function is only ever called exactly once?

Copy link
Contributor

Choose a reason for hiding this comment

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

Since filterKeys is a function itself, I suspect it doesn't matter.

Comment on lines +29 to +31
(lib.mapAttrsToList (_: lib.attrValues))
lib.concatLists
(lib.flip lib.genAttrs (_: true))
Copy link
Contributor

Choose a reason for hiding this comment

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

My mind tells me there's an opportunity to use builtins.intersectAttrs here to good effect, but I'm too lazy to do the work needed to productionize it.

It also tells me that there's something in builtins.hasAttr that might be of use below but I'm not sure what exactly.

@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 2 This PR was reviewed and approved by two persons. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels Aug 6, 2025
@wolfgangwalther wolfgangwalther merged commit 3c004e5 into NixOS:master Aug 6, 2025
27 of 29 checks passed
@wolfgangwalther wolfgangwalther deleted the ci-renamed-rebuilds branch August 6, 2025 19:21
@nixpkgs-ci
Copy link
Contributor

nixpkgs-ci bot commented Aug 6, 2025

Successfully created backport PR for release-25.05:

@github-actions github-actions bot added the 8.has: port to stable This PR already has a backport to the stable release. label Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions 8.has: port to stable This PR already has a backport to the stable release. 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: 2 This PR was reviewed and approved by two persons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants