1
1
forked from extern/flakelight

Fix merge function for custom option types

If merge is not set for an option type, it will use the default merge
function; this was not what was intended. Updated the merge values for
options that did not set one to mergeOneOption or mergeEqualOption.
This commit is contained in:
Archit Gupta 2023-10-18 19:58:23 -07:00
parent b0fd6a391c
commit fad306c589
2 changed files with 5 additions and 0 deletions

View File

@ -7,6 +7,7 @@ let
inherit (builtins) isPath isString;
inherit (lib) mkOption mkOptionType mkIf mkMerge;
inherit (lib.types) lazyAttrsOf nullOr;
inherit (lib.options) mergeEqualOption;
template = mkOptionType {
name = "template";
@ -15,6 +16,7 @@ let
check = x: (x ? path) && (isPath x.path) &&
(x ? description) && (isString x.description) &&
((! x ? welcomeText) || (isString x.welcomeText));
merge = mergeEqualOption;
};
in
{

View File

@ -10,6 +10,7 @@ let
mapAttrsToList pathExists pipe removePrefix removeSuffix evalModules
mkDefault mkOptionType singleton;
inherit (nixpkgs.lib.types) coercedTo functionTo listOf;
inherit (nixpkgs.lib.options) mergeEqualOption mergeOneOption;
builtinModules = mapAttrsToList (k: _: ./builtinModules + ("/" + k))
(readDir ./builtinModules);
@ -49,6 +50,7 @@ let
description = "package definition";
descriptionClass = "noun";
check = isFunction;
merge = mergeOneOption;
};
path = mkOptionType {
@ -56,6 +58,7 @@ let
description = "path";
descriptionClass = "noun";
check = isPath;
merge = mergeEqualOption;
};
module = mkOptionType {