Skip to content

Bring back functionTo to prevent evalutation errors while merging#44626

Closed
basvandijk wants to merge 3 commits intoNixOS:masterfrom
LumiGuide:bring-back-functionTo
Closed

Bring back functionTo to prevent evalutation errors while merging#44626
basvandijk wants to merge 3 commits intoNixOS:masterfrom
LumiGuide:bring-back-functionTo

Conversation

@basvandijk
Copy link
Copy Markdown
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.
@basvandijk basvandijk requested review from edolstra and nbp August 7, 2018 17:08
@GrahamcOfBorg GrahamcOfBorg added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Aug 7, 2018
@nbp
Copy link
Copy Markdown
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

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants