mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 13:15:30 +03:00
Remove obsolete function addDefaultOptionValues
This commit is contained in:
parent
f8a9eb9f00
commit
c9dad37f01
2 changed files with 4 additions and 28 deletions
|
@ -30,31 +30,6 @@ rec {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
};
|
};
|
||||||
|
|
||||||
# !!! This function will be removed because this can be done with the
|
|
||||||
# multiple option declarations.
|
|
||||||
addDefaultOptionValues = defs: opts: opts //
|
|
||||||
builtins.listToAttrs (map (defName:
|
|
||||||
{ name = defName;
|
|
||||||
value =
|
|
||||||
let
|
|
||||||
defValue = builtins.getAttr defName defs;
|
|
||||||
optValue = builtins.getAttr defName opts;
|
|
||||||
in
|
|
||||||
if isOption defValue
|
|
||||||
then
|
|
||||||
# `defValue' is an option.
|
|
||||||
if hasAttr defName opts
|
|
||||||
then builtins.getAttr defName opts
|
|
||||||
else defValue.default
|
|
||||||
else
|
|
||||||
# `defValue' is an attribute set containing options.
|
|
||||||
# So recurse.
|
|
||||||
if hasAttr defName opts && isAttrs optValue
|
|
||||||
then addDefaultOptionValues defValue optValue
|
|
||||||
else addDefaultOptionValues defValue {};
|
|
||||||
}
|
|
||||||
) (attrNames defs));
|
|
||||||
|
|
||||||
mergeDefaultOption = args: list:
|
mergeDefaultOption = args: list:
|
||||||
if length list == 1 then head list
|
if length list == 1 then head list
|
||||||
else if all builtins.isFunction list then x: mergeDefaultOption args (map (f: f x) list)
|
else if all builtins.isFunction list then x: mergeDefaultOption args (map (f: f x) list)
|
||||||
|
@ -65,7 +40,6 @@ rec {
|
||||||
else if all builtins.isInt list && all (x: x == head list) list then head list
|
else if all builtins.isInt list && all (x: x == head list) list then head list
|
||||||
else throw "Cannot merge definitions of `${showOption args.prefix}' given in ${showFiles args.files}.";
|
else throw "Cannot merge definitions of `${showOption args.prefix}' given in ${showFiles args.files}.";
|
||||||
|
|
||||||
|
|
||||||
/* Obsolete, will remove soon. Specify an option type or apply
|
/* Obsolete, will remove soon. Specify an option type or apply
|
||||||
function instead. */
|
function instead. */
|
||||||
mergeTypedOption = typeName: predicate: merge: args: list:
|
mergeTypedOption = typeName: predicate: merge: args: list:
|
||||||
|
|
|
@ -47,8 +47,10 @@ let
|
||||||
svcFunction =
|
svcFunction =
|
||||||
if svc ? function then svc.function
|
if svc ? function then svc.function
|
||||||
else import "${./.}/${if svc ? serviceType then svc.serviceType else svc.serviceName}.nix";
|
else import "${./.}/${if svc ? serviceType then svc.serviceType else svc.serviceName}.nix";
|
||||||
config = addDefaultOptionValues res.options
|
config = (evalModules
|
||||||
(if svc ? config then svc.config else svc);
|
{ modules = [ { options = res.options; config = svc.config or svc; } ];
|
||||||
|
check = false;
|
||||||
|
}).config;
|
||||||
defaults = {
|
defaults = {
|
||||||
extraConfig = "";
|
extraConfig = "";
|
||||||
extraModules = [];
|
extraModules = [];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue