From fad306c58965fd33358c48f2b9d4931bd306cfb4 Mon Sep 17 00:00:00 2001 From: Archit Gupta Date: Wed, 18 Oct 2023 19:58:23 -0700 Subject: [PATCH] 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. --- builtinModules/templates.nix | 2 ++ default.nix | 3 +++ 2 files changed, 5 insertions(+) diff --git a/builtinModules/templates.nix b/builtinModules/templates.nix index 4deaf4b..c02a75b 100644 --- a/builtinModules/templates.nix +++ b/builtinModules/templates.nix @@ -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 { diff --git a/default.nix b/default.nix index 778ab1f..ba4ee8a 100644 --- a/default.nix +++ b/default.nix @@ -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 {