Skip to content

lib.makeOverridable: preserve constructor override and metadata attributes#461032

Merged
roberth merged 1 commit intoNixOS:masterfrom
ShamrockLee:lib-makeOverridable-metadata
Dec 22, 2025
Merged

lib.makeOverridable: preserve constructor override and metadata attributes#461032
roberth merged 1 commit intoNixOS:masterfrom
ShamrockLee:lib-makeOverridable-metadata

Conversation

@ShamrockLee
Copy link
Contributor

@ShamrockLee ShamrockLee commented Nov 12, 2025

Description

The local lib.makeOverridable for fetchers (added by PR #158968) drops the metadata attributes lib.extendMkDerivationattaches to the fetchers.

This PR fixes lib.makeOverridable to preserve the additional attributes. when the function to decorate is a callable attribute set.

Background

During the pre-finalAttrs era, PR #158968 uses lib.makeOverridable to add a custom overrider override to the result FOD of several fetchers in order to workaround the limitation of <pkg>.overrideAttrs.

However, lib.makeOverride was initially designed to be used by callPackage and provide the typical <pkg>.override interface, which doesn't take into account functions that has already been called with callPackage or callable attribute set containing extra attribuets (e.g., the ones defined with lib.extendMkDerivation).

Considering that those custom overriders will stay in Nixpkgs for quite some time, lib.makeOverridable should be able to handle those edge cases.

Quick validation

  • Evaluate pkgs.fetchgit. After this change, the lib.extendMkDerivation-provided metadata attributes (constructDrv, excludeDrvArgNames, extendDrvArgs, transformDrv) will show up.

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.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 6.topic: lib The Nixpkgs function library labels Nov 12, 2025
@ShamrockLee
Copy link
Contributor Author

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 461032
Commit: d4eb6bcfb4f6f234ee13413546b441fc99391e6e (subsequent changes)
Merge: 81327c1b4d1007d8a5f54d9f9dcecf53de86c6df

Logs: https://github.com/ShamrockLee/nixpkgs-review-gha/actions/runs/19313832710


x86_64-linux

⏩ 2 packages blacklisted:
  • nixos-install-tools
  • tests.nixos-functions.nixos-test
✅ 3 packages built:
  • extra-container
  • nixos-container
  • nixpkgs-manual

aarch64-linux

⏩ 2 packages blacklisted:
  • nixos-install-tools
  • tests.nixos-functions.nixos-test
✅ 3 packages built:
  • extra-container
  • nixos-container
  • nixpkgs-manual

x86_64-darwin (sandbox = relaxed)

✅ 1 package built:
  • nixpkgs-manual

aarch64-darwin (sandbox = relaxed)

✅ 1 package built:
  • nixpkgs-manual

@ShamrockLee ShamrockLee marked this pull request as ready for review November 13, 2025 00:22
@ShamrockLee ShamrockLee force-pushed the lib-makeOverridable-metadata branch from d4eb6bc to 21021ad Compare November 13, 2025 10:02
@ShamrockLee
Copy link
Contributor Author

Test cases added.

@nixpkgs-ci nixpkgs-ci bot requested review from hsjobeki and infinisil November 13, 2025 10:08
@philiptaron philiptaron changed the title lib.makeOverrdable: preserve constructor override and metadata attributes lib.makeOverridable: preserve constructor override and metadata attributes Nov 26, 2025
Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

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

I despise this function, but until we replace it with a simpler concept, we may as well try and make the most of it.

@roberth
Copy link
Member

roberth commented Dec 22, 2025

The tests are much appreciated ❤️

@roberth roberth added this pull request to the merge queue Dec 22, 2025
@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Dec 22, 2025
Merged via the queue into NixOS:master with commit 34b2f67 Dec 22, 2025
33 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: lib The Nixpkgs function library 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants