To clarify, https://github.com/NixOS/nixpkgs/pull/234651 alone doesn’t solve the “arguments not overridable via the <pkg>.overrideAttrs” issue.
To make cargoHash overridable in buildRustPackage-constructed packages, we need to utilize the fixed-point arguments support of the base build helper and refer to cargoHash as finalAttrs.cargoHash or finalAttrs.passthru.cargoHash to use the overridden version.
For rustPlatform.buildRustPackage, the base build helper is stdenv.mkDerivation, which already supports fixed-point arguments. While for build helpers that are not directly based on stdenv.mkDerivation, it would be helpful to refactor the base build helper with lib.extendMkDerivation.
We underwent a similar transition to make vendorHash overridable for buildGoModule-constructed packages:
NixOS:staging ← ShamrockLee:go-module-overlay-stdenv
opened 09:32PM - 06 Apr 23 UTC
###### Description of changes
The Go package builder `buildGoModule` is refac… tored to adopt the overlay-style `stdenv.mkDerivation` (#119942) and to fix overriding. One can now override `vendorHash` using `overrideAttrs`. This addresses https://github.com/NixOS/nixpkgs/issues/86349#issuecomment-763914147
The `goModules` and `vendorHash` attributes are moved out of `passthru` as they are already exposed as `stdenv.mkDerivation` attributes. They can still be accessed as `pet.vendorHash`, but no longer `pet.passthru.vendorHash`. The builder now only adds `go` to `passthru`.
To address the issue of `vendorHash = null` through `overrideAttrs` may break the overriding of `goModules`, this PR also provides an overridable `passthru.overrideModAttrs` that will be applied to `goModules` when `vendorHash` is not `null`.
Closes #86349
Comparison to similar PRs:
In this PR, the diff of `pkgs/build-support/go/module.nix` is shorter than #171586.
<!--
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
- Built on platform(s)
- [X] x86_64-linux
- [ ] aarch64-linux
- [ ] x86_64-darwin
- [ ] aarch64-darwin
- [ ] For non-Linux: Is `sandbox = true` set in `nix.conf`? (See [Nix manual](https://nixos.org/manual/nix/stable/command-ref/conf-file.html))
- [ ] Tested, as applicable:
- [NixOS test(s)](https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests) (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
- and/or [package tests](https://nixos.org/manual/nixpkgs/unstable/#sec-package-tests)
- or, for functions and "core" functionality, tests in [lib/tests](https://github.com/NixOS/nixpkgs/blob/master/lib/tests) or [pkgs/test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/test)
- made sure NixOS tests are [linked](https://nixos.org/manual/nixpkgs/unstable/#ssec-nixos-tests-linking) to the relevant packages
- [ ] 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](https://github.com/Mic92/nixpkgs-review#usage)
- [ ] Tested basic functionality of all binary files (usually in `./result/bin/`)
- [23.05 Release Notes (or backporting 22.11 Release notes)](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#generating-2305-release-notes)
- [X] (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
- [X] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
<!--
To help with the large amounts of pull requests, we would appreciate your
reviews of other pull requests, especially simple package updates. Just leave a
comment describing what you have tested in the relevant package/service.
Reviewing helps to reduce the average time-to-merge for everyone.
Thanks a lot if you do!
List of open PRs: https://github.com/NixOS/nixpkgs/pulls
Reviewing guidelines: https://nixos.org/manual/nixpkgs/unstable/#chap-reviewing-contributions
-->
A more complex transition for Python packages to use overrideAttrs instead of overridePythonAttrs is underway. Reviews and feedbacks are welcome:
NixOS:master ← ShamrockLee:build-python-direct-overriding-simple
opened 12:00PM - 24 Jan 25 UTC
This PR makes the following attributes overridable using `overrideAttrs`:
- `… src`
- `removePythonDeps`
- `relaxPythonDeps`
- `passthru.build-system`
- `passthru.dependencies`
- `passthru.pyproject`
Depends on (the diff will shorten once the dependency merges):
- #375921
Related PRs:
- Fix `disabled` and make `passthru.disabled` overridable using `overrideAttrs`:
- #267296
- #376419
- Fix `name` and make `pname` and `version` overridable using `overrideAttrs`:
- #376714
- Make the check-related attributes overridable using `overrideAttrs`:
- #376060
## 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](https://nixos.org/manual/nix/stable/command-ref/conf-file.html))
- [ ] `sandbox = relaxed`
- [ ] `sandbox = true`
- [ ] Tested, as applicable:
- [NixOS test(s)](https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests) (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
- and/or [package tests](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-tests)
- or, for functions and "core" functionality, tests in [lib/tests](https://github.com/NixOS/nixpkgs/blob/master/lib/tests) or [pkgs/test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/test)
- made sure NixOS tests are [linked](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#linking-nixos-module-tests-to-a-package) to the relevant packages
- [ ] 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](https://github.com/Mic92/nixpkgs-review#usage)
- [ ] Tested basic functionality of all binary files (usually in `./result/bin/`)
- [25.05 Release Notes](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2505.section.md) (or backporting [24.11](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2411.section.md) and [25.05](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2505.section.md) 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](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
<!--
To help with the large amounts of pull requests, we would appreciate your
reviews of other pull requests, especially simple package updates. Just leave a
comment describing what you have tested in the relevant package/service.
Reviewing helps to reduce the average time-to-merge for everyone.
Thanks a lot if you do!
List of open PRs: https://github.com/NixOS/nixpkgs/pulls
Reviewing guidelines: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#reviewing-contributions
-->
---
Add a :+1: [reaction] to [pull requests you find important].
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc
4 Likes