Skip to content

lib.types.anything: Add functionArgs#266105

Open
roberth wants to merge 1 commit intoNixOS:masterfrom
hercules-ci:lib-types-anything-add-functionArgs
Open

lib.types.anything: Add functionArgs#266105
roberth wants to merge 1 commit intoNixOS:masterfrom
hercules-ci:lib-types-anything-add-functionArgs

Conversation

@roberth
Copy link
Member

@roberth roberth commented Nov 7, 2023

Description of changes

Make function reflection work even when types.anything mediates the value.

I'm not a big fan of function reflection, or types.anything, because both are broken concepts, but this at least fixes the use case where a function is expected and passed to, say, callPackage or evalModules, etc.

I have chosen not to apply this change to functionTo, because this solution has a performance cost, and perhaps usages of functionTo are better - by not using reflection.

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: module system About "NixOS" module system internals 6.topic: lib The Nixpkgs function library labels Nov 7, 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 7, 2023
@infinisil
Copy link
Member

Where did this turn up to be necessary?

@roberth
Copy link
Member Author

roberth commented Nov 27, 2023

I think it was a solution to a problem with two solutions - one being this PR and the other one being:

The original problem was in a private repo, but if I recall correctly, anything was interfering with the application of module arguments, which, as you know, behaves a bit like

as it relies on reflection.

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.

Minor suggestions, looks fine overall!

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one person. label Mar 8, 2024
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label May 3, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
@rhendric
Copy link
Member

rhendric commented Apr 1, 2025

Recently found myself in want of this, but it looks like this PR was abandoned. Any interest in reviving it, or should I open a new one?

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 1, 2025
I'm not a big fan of function reflection, or types.anything, because
both are broken concepts, but this at least fixes the use case where a
function is expected and passed to, say, callPackage or evalModules, etc.

I have chosen not to apply this change to functionTo, because this
solution has a performance cost, and perhaps usages of functionTo are
better - by not using reflection.
@roberth roberth force-pushed the lib-types-anything-add-functionArgs branch from 4521b4f to 78d4dcf Compare April 1, 2025 09:33
@roberth
Copy link
Member Author

roberth commented Apr 1, 2025

Rebased, applied suggestions, tests pass locally. Can be merged if ofborg agrees.

EDIT: ignore nixfmt, because types.nix wasn't formatted

@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Apr 1, 2025
@nix-owners nix-owners bot requested a review from hsjobeki April 1, 2025 09:35
@github-actions github-actions bot added 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. labels Apr 1, 2025
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Apr 2, 2025
@qweered
Copy link
Contributor

qweered commented Sep 28, 2025

Needs rebase

@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 2 This PR was reviewed and approved by two persons. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: lib The Nixpkgs function library 6.topic: module system About "NixOS" module system internals 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: 2 This PR was reviewed and approved by two persons.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

5 participants