Skip to content

lib.mirrorFunctionArgs: init#265710

Merged
infinisil merged 3 commits intoNixOS:masterfrom
ShamrockLee:lib-copy-function-args
Nov 14, 2023
Merged

lib.mirrorFunctionArgs: init#265710
infinisil merged 3 commits intoNixOS:masterfrom
ShamrockLee:lib-copy-function-args

Conversation

@ShamrockLee
Copy link
Contributor

@ShamrockLee ShamrockLee commented Nov 5, 2023

Description of changes

Add lib.mirrorFunctionArgs f g as an intuitive shorthand of lib.setFunctionArgs g (lib.functionArgs f), with optimization that caches the lib.functionArgs f result when partially applied.

Use it in the definition of lib.makeOverridable and makeOverridablePythonPackage.

The changes are split from #234651 to ease the review workload up with smaller PRs.

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/)
  • 23.11 Release Notes (or backporting 23.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.

@github-actions github-actions bot added 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: lib The Nixpkgs function library labels Nov 5, 2023
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Nov 5, 2023
lib/trivial.nix Outdated
Copy link
Member

Choose a reason for hiding this comment

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

Side note: This doesn't render in nixdoc right now, but I think we can keep it anyways

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that, too. It would be fine as long as the function description doesn't depend on the argument name used here.

Nevertheless, I do hope that the second one could get rendered in the future.

ShamrockLee and others added 3 commits November 7, 2023 01:58
Co-authored-by: Silvan Mosberger <[email protected]>
Rename temporary variable copyArgs -> mirrorArgs.
Use lib.mirrorFunctionArgs to define `mirrorArgs`.
Apply mirrorArgs also to the returned function.
@ShamrockLee ShamrockLee force-pushed the lib-copy-function-args branch from f232c50 to b3e2c15 Compare November 7, 2023 02:00
@ShamrockLee ShamrockLee changed the title lib.copyFunctionArgs: init lib.mirrorFunctionArgs: init Nov 7, 2023
@ShamrockLee ShamrockLee requested a review from infinisil November 7, 2023 02:08
@ShamrockLee ShamrockLee mentioned this pull request Nov 8, 2023
13 tasks
Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

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

Looking good!

@infinisil infinisil merged commit 7eddbf5 into NixOS:master Nov 14, 2023
@ShamrockLee ShamrockLee deleted the lib-copy-function-args branch November 14, 2023 14:00
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 6.topic: python Python is a high-level, general-purpose programming language. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants