Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back functionTo to prevent evalutation errors while merging #44626

Closed
wants to merge 3 commits into from

Conversation

basvandijk
Copy link
Member

Motivation for this change

This is an alternative for #44601 as suggested by @oxij .

This is used to type options like: services.xserver.windowManager.xmonad.extraPackages that specify functions that take an attribute set containing packages / plugins and return a list containing a selection of the values in this set.

The reason we need a dedicated type for this is to define the correct merge behaviour. Without the functionTo type merging multiple function option definitions results in an evaluation error.
The functionTo merges definitions by returning a new function that applies the functions of all the definitions to the given input and merges the results.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

This reverts commit 4ff1ab5.

We need this to type options like:
services.xserver.windowManager.xmonad.extraPackages that specify functions that
take an attribute set containing packages / plugins and return a list containing
a selection of the values in this set.

The reason we need a dedicated type for this is to have the correct merge
behaviour. Without the functionTo type merging multiple function option
definitions results in an evaluation error. The functionTo type merges
definitions by returning a new function that applies the functions of all the
definitions to the given input and merges the result.
Without this patch merging options like
services.xserver.windowManager.xmonad.extraPackages
results in the evaluation error:

  error: value is a list while a set was expected, at nixpkgs/lib/options.nix:77:23

With this patch we get the desired merging behaviour that just concatenates the
resulting package lists.
@nbp
Copy link
Member

nbp commented Aug 7, 2018

This is an alternative for #44601 as suggested by @oxij .

This alternative would be the last on the list of things to be added back. This was a mistake, and we have plenty of alternative before going back to such extreme. (see #44601 (comment))

Short answer: No!

@nbp nbp closed this Aug 7, 2018
@infinisil infinisil mentioned this pull request Jan 24, 2021
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants