lib/customisation: add overrideVariant to preserve API in by-name migrations, fix formatting in docstring #537454
:white_check_mark: nixpkgs-review result
Generated using nixpkgs-review-gha (da739d6)
Command: nixpkgs-review pr 537454
Commit: 05ae943c9645d9a0256f30ef22c76a1a67914797 (subsequent changes)
Merge: 962ecb728ce325df9fbd4442714bb68b9d155992
Logs: https://github.com/guylamar2006/nixpkgs-review-gha/actions/runs/28526580304/attempts/1
---
x86_64-linux
<details>
<summary>:fast_forward: 2 packages blacklisted:</summary>
<ul>
<li>nixos-install-tools</li>
<li>tests.nixos-functions.nixos-test</li>
</ul>
</details>
<details>
<summary>:white_check_mark: 4 packages built:</summary>
<ul>
<li>extra-container</li>
<li>nixos-container</li>
<li>nixpkgs-manual</li>
<li>tests.lib-tests</li>
</ul>
</details>
---
aarch64-linux
<details>
<summary>:fast_forward: 2 packages blacklisted:</summary>
<ul>
<li>nixos-install-tools</li>
<li>tests.nixos-functions.nixos-test</li>
</ul>
</details>
<details>
<summary>:white_check_mark: 4 packages built:</summary>
<ul>
<li>extra-container</li>
<li>nixos-container</li>
<li>nixpkgs-manual</li>
<li>tests.lib-tests</li>
</ul>
</details>
---
aarch64-darwin (sandbox = relaxed)
<details>
<summary>:white_check_mark: 2 packages built:</summary>
<ul>
<li>nixpkgs-manual</li>
<li>tests.lib-tests</li>
</ul>
</details>
Accidental? Intentional?
I generally like the idea, but haven't reviewed the implementation too closely
Accidental! My AI assistant slipped a comment token in there while formatting the file, and I didn't catch it before pushing. I am reverting it now so we don't break callPackage reflection for custom builder arguments.
Could mkOverrideVariant be a more intuitive name?
I wonder if automatically adding basePackage to the exclusion list could be a good idea. I imagine in a lot of cases that would be the only thing being explicitly removed. (It may make calls of the function less understandable, though.. is there a way to not require the empty list?) Maybe that could break packages which use themselves in tests though... but I think finalAttrs.finalPackage is the idiomatic way to do that now.
Thanks for taking this up. Just a few thoughts from a quick lookthrough, but I'm no lib expert, so take them with a grain of salt.
SandaruKasa
guylamar2006
This pull request introduces a new utility function to simplify package variant overrides and migrates two packages to use this approach. The main focus is to facilitate the "by-name" migration for package variants, making it easier to override and extend packages without losing the ability to chain
.overridecalls. Additionally, the documentation for related functions has been improved for clarity.New utility for package overrides:
Added the
overrideVariantfunction tolib/customisation.nix, allowing clean and flexible overriding of base packages with specific attributes and passthrough arguments. This is designed to support the "by-name" migration and preserve.overridechaining for package variants.Migration to new override utility:
Updated
pkgs/by-name/ja/jabcode-reader/package.nixandpkgs/by-name/ja/jabcode-writer/package.nixto uselib.customisation.overrideVariantinstead of manual override logic, improving maintainability and consistency. [[1]](diffhunk://#diff-f8e7031be16152262f7fb3f3c12046ce899b1390aac24828f120afa3bfebb1e2R2-R9) [[2]](diffhunk://#diff-38f23ebbe7f428cc9054f58b758faad5094e5ca98c661a58250d0be4c950bdc0R2-R9)Documentation improvements:
Enhanced the documentation for
callPackageWithinlib/customisation.nixwith clearer examples and explanations for easier understanding and usage.Code cleanup:
Commented out an unused line related to function argument inheritance in
lib/customisation.nixto avoid confusion and maintain code clarity.Abstract overrideAttrs logic for issue #537188
<!--
^ Please summarise the changes you have done and explain why they are necessary here ^
For package updates please link to a changelog or describe changes, this helps your fellow maintainers discover breaking updates.
For new packages please briefly describe the package or provide a link to its homepage.
-->
Things done
<!-- Please check what applies. Note that these are not hard requirements but merely serve as information for reviewers. -->
- [x] x86_64-linux
- [ ] aarch64-linux
- [ ] aarch64-darwin
- [ ] [NixOS tests] in [nixos/tests].
- [ ] [Package tests] at
passthru.tests.- [ ] Tests in [lib/tests] or [pkgs/test] for functions and "core" functionality.
nixpkgs-reviewon this PR. See [nixpkgs-review usage]../result/bin/.- [ ] Package update: when the change is major or breaking.
- [ ] Module addition: when adding a new NixOS module.
- [ ] Module update: when the change is significant.
[NixOS tests]: https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests
[Package tests]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-tests
[nixpkgs-review usage]: https://github.com/Mic92/nixpkgs-review#usage
[CONTRIBUTING.md]: https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md
[automation/AI policy]: https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#automationai-policy
[lib/tests]: https://github.com/NixOS/nixpkgs/blob/master/lib/tests
[maintainers/README.md]: https://github.com/NixOS/nixpkgs/blob/master/maintainers/README.md
[nixos/tests]: https://github.com/NixOS/nixpkgs/blob/master/nixos/tests
[pkgs/README.md]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md
[pkgs/test]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/test