mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-04-17 05:48:38 +00:00
Revert "Remove types.functionTo."
This reverts commit4ff1ab5a56
. 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. (cherry picked from commit7ed41ff5e7
)
This commit is contained in:
parent
5c7e19604e
commit
b454af298d
@ -453,6 +453,16 @@ rec {
|
||||
functor = (defaultFunctor name) // { wrapped = elemType; };
|
||||
};
|
||||
|
||||
functionTo = elemType: mkOptionType {
|
||||
name = "function that evaluates to a(n) ${elemType.name}";
|
||||
check = isFunction;
|
||||
merge = loc: defs:
|
||||
fnArgs: elemType.merge loc (map (fn: { inherit (fn) file; value = fn.value fnArgs; }) defs);
|
||||
getSubOptions = elemType.getSubOptions;
|
||||
getSubModules = elemType.getSubModules;
|
||||
substSubModules = m: functionTo (elemType.substSubModules m);
|
||||
};
|
||||
|
||||
# A submodule (like typed attribute set). See NixOS manual.
|
||||
submodule = modules: submoduleWith {
|
||||
shorthandOnlyDefinesConfig = true;
|
||||
|
Loading…
Reference in New Issue
Block a user