Skip to content
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

build-support/php: support lib.extendMkDerivation #385830

Merged
merged 2 commits into from
Mar 1, 2025

Conversation

drupol
Copy link
Contributor

@drupol drupol commented Feb 28, 2025

The PHP builders were supporting the finalAttrs pattern from the beginning (thanks @jtojnar for this!). This PR update the builders using lib.extendMkDerivation.

Inspired from #382550

Context: #234651

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/)
  • 25.05 Release Notes (or backporting 24.11 and 25.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.

@drupol
Copy link
Contributor Author

drupol commented Feb 28, 2025

@ofborg build phpunit phpPackages.psalm

@drupol drupol marked this pull request as ready for review February 28, 2025 17:48
Copy link
Contributor

@JohnRTitor JohnRTitor left a comment

Choose a reason for hiding this comment

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

Passes my eyeball test

@JohnRTitor JohnRTitor merged commit cd850d5 into NixOS:master Mar 1, 2025
57 of 59 checks passed
@drupol drupol deleted the push-vnunotrsurnz branch March 1, 2025 10:05
@ShamrockLee
Copy link
Contributor

Going through the diff, this PR seems to change the way vendorHash gets overridden. The build helpers previously supports <php package>.overrideAttrs { vendorHash = <new hash>; }, but now the overriding is only possible via overriding composerVendor.

@jtojnar
Copy link
Member

jtojnar commented Mar 2, 2025

@JohnRTitor For non-leaf packages, and especially far reaching changes like this, there should be a longer review period. Probably at least a week, since many contributors only have time for review e.g. during weekends.

@ShamrockLee
Copy link
Contributor

Going through the diff, this PR seems to change the way vendorHash gets overridden. The build helpers previously supports <php package>.overrideAttrs { vendorHash = <new hash>; }, but now the overriding is only possible via overriding composerVendor.

If this interface change is intended, there should be a release note entry under the "Backward incompatibility" sub-section. If not, it is easy to fix -- just add back the finalAttrs inheritance of cargoHash.

@JohnRTitor
Copy link
Contributor

@JohnRTitor For non-leaf packages, and especially far reaching changes like this, there should be a longer review period. Probably at least a week, since many contributors only have time for review e.g. during weekends.

Thanks, I will keep this in mind, though I thought this was a straightforward change.

inherit (finalAttrs)
patches
pname
src
vendorHash
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is intended? @drupol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this was intended indeed. Is there any issue?

@drupol
Copy link
Contributor Author

drupol commented Mar 3, 2025

For some unknown reasons, I received all the Github notifications from this thread now.

Let me know if there are adjustments to do and I'll gladly do it. So far, from the tests I made, I haven't encountered any issue.

@ShamrockLee
Copy link
Contributor

ShamrockLee commented Mar 3, 2025

Here's a minimal, Nix REPL-based reproducer that shows the changes of overriding behaviour.

After this PR:

nixpkgs_losslesscut on  HEAD (359c7c9) [$] nix repl
Nix 2.24.10
Type :? for help.
nix-repl> lib = import ./lib                                           

nix-repl> pkgs = import ./. { config = { allowAliases = false; checkMeta = true; }; } 

nix-repl> pkgs.phpPackages.php-parallel-lint                           
«derivation /nix/store/ydvfkm3d61pmnwnnbm7xz44j73l19vwx-php-parallel-lint-1.4.0.drv»

nix-repl> pkgs.phpPackages.php-parallel-lint.vendorHash                
"sha256-ySdLlqlGKZ6LgmAOBMkBNoCAqWrgMwE/Cj6ZEPEsCko="

nix-repl> pkgs.phpPackages.php-parallel-lint.composerVendor            
«derivation /nix/store/zpshq5qc1nl6v17dhpbb27n844z32pli-php-parallel-lint-composer-vendor-1.4.0.drv»

nix-repl> pkgs.phpPackages.php-parallel-lint.composerVendor.outputHash 
"sha256-ySdLlqlGKZ6LgmAOBMkBNoCAqWrgMwE/Cj6ZEPEsCko="

nix-repl> (pkgs.phpPackages.php-parallel-lint.overrideAttrs { vendorHash = lib.fakeHash; })                           
«derivation /nix/store/61zgmy4zd55g65c880pv7znfm5p44mxc-php-parallel-lint-1.4.0.drv»

nix-repl> (pkgs.phpPackages.php-parallel-lint.overrideAttrs { vendorHash = lib.fakeHash; }).vendorHash
"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="

nix-repl> (pkgs.phpPackages.php-parallel-lint.overrideAttrs { vendorHas
h = lib.fakeHash; }).composerVendor
«derivation /nix/store/zpshq5qc1nl6v17dhpbb27n844z32pli-php-parallel-lint-composer-vendor-1.4.0.drv»

nix-repl> (pkgs.phpPackages.php-parallel-lint.overrideAttrs { vendorHas
h = lib.fakeHash; }).composerVendor.outputHash
"sha256-ySdLlqlGKZ6LgmAOBMkBNoCAqWrgMwE/Cj6ZEPEsCko="

Before this PR:

nixpkgs_losslesscut on  HEAD (d857a85) [$] nix repl
Nix 2.24.10
Type :? for help.
nix-repl> lib = import ./lib                                           

nix-repl> pkgs = import ./. { config = { allowAliases = false; checkMeta = true; }; }                                 

nix-repl> pkgs.phpPackages.php-parallel-lint                           
«derivation /nix/store/xdild3457dac1937f20lrzhnqq0546mg-php-parallel-lint-1.4.0.drv»

nix-repl> pkgs.phpPackages.php-parallel-lint.vendorHash                
"sha256-ySdLlqlGKZ6LgmAOBMkBNoCAqWrgMwE/Cj6ZEPEsCko="

nix-repl> pkgs.phpPackages.php-parallel-lint.composerVendor            
«derivation /nix/store/49k377wlvckalhqg71mba1ygmwd0k8n2-php-parallel-lint-composer-repository-1.4.0.drv»

nix-repl> pkgs.phpPackages.php-parallel-lint.composerVendor.outputHash 
"sha256-ySdLlqlGKZ6LgmAOBMkBNoCAqWrgMwE/Cj6ZEPEsCko="

nix-repl> (pkgs.phpPackages.php-parallel-lint.overrideAttrs { vendorHash = lib.fakeHash; })                           
«derivation /nix/store/7lg86qm6m9q97qdzls0hqn8sxmvvl08x-php-parallel-lint-1.4.0.drv»

nix-repl> (pkgs.phpPackages.php-parallel-lint.overrideAttrs { vendorHash = lib.fakeHash; }).vendorHash                
"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="

nix-repl> (pkgs.phpPackages.php-parallel-lint.overrideAttrs { vendorHash = lib.fakeHash; }).composerVendor            
«derivation /nix/store/xn7pxq9djyrc8dcpqlg4kdm5i7fmskvx-php-parallel-lint-composer-repository-1.4.0.drv»

nix-repl> (pkgs.phpPackages.php-parallel-lint.overrideAttrs { vendorHash = lib.fakeHash; }).composerVendor.outputHash
"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="



nixpkgs_losslesscut on  HEAD (d857a85) [$] took 48s 

@drupol
Copy link
Contributor Author

drupol commented Mar 3, 2025

OK I see.

Then, with these changes introduced in this PR, there's no way to override the vendorHash any more?
If that's true, I'll update it tonight.

@ShamrockLee
Copy link
Contributor

phpPackages.php-parallel-lint.overrideAttrs (
  previousAttrs:
  {
    composerVendor = previousAttrs.composerVendor.overrideAttrs (
      previousAttrs: {
        vendorHash = "new vendorHash";
      });
  })

and

phpPackages.php-parallel-lint.overrideAttrs (
  previousAttrs:
  {
    composerVendor = previousAttrs.composerVendor.overrideAttrs (
      previousAttrs: {
        outputHash = "new vendorHash";
      });
  })

still work.

The core issue is, which way of overriding is officially supported?

There should be one-- and preferably only one --obvious way to do it.

And it/its change require documentation.

@drupol
Copy link
Contributor Author

drupol commented Mar 3, 2025

OK.

I'll rework all of this tonight.

@JohnRTitor
Copy link
Contributor

Do we want a revert in the meantime since this breaks existing behaviour?

@drupol
Copy link
Contributor Author

drupol commented Mar 3, 2025

I don't think it is necessary, tonight there will be a fix.

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

Successfully merging this pull request may close these issues.

4 participants