From 5c0c8a40170b86da6ba2c76228b98546aef186a3 Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Tue, 29 Sep 2009 15:21:36 +0000 Subject: [PATCH] Add messages inside the renaming process to force user to rename their options. Add the "deprecated" status which breaks until options are manually renamed. svn path=/nixos/trunk/; revision=17508 --- modules/rename.nix | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/modules/rename.nix b/modules/rename.nix index fd936c7a4461..c68d59b2e18d 100644 --- a/modules/rename.nix +++ b/modules/rename.nix @@ -3,16 +3,38 @@ let to = throw "This is just a dummy keyword"; - alias = { name = "Alias"; }; - obsolete = { name = "Obsolete name"; }; + + alias = from: to: { + name = "Alias"; + msg.use = x: x; + msg.define = x: x; + }; + + obsolete = from: to: { + name = "Obsolete name"; + msg.use = x: + builtins.trace "Option '${from}' is used instead of '${to}'." x; + msg.define = x: + builtins.trace "Option '${from}' is defined instead of '${to}'." x; + }; + + deprecated = from: to: { + name = "Deprecated name"; + msg.use = x: + abort "Option '${from}' is used instead of '${to}'."; + msg.define = x: + abort "Option '${from}' is defined instead of '${to}'."; + }; + zipModules = list: with pkgs.lib; zip (n: v: if tail v != [] then zipModules v else head v ) list; - rename = fromStatus: from: keyword: to: with pkgs.lib; + rename = statusTemplate: from: keyword: to: with pkgs.lib; let + status = statusTemplate from to; setTo = setAttrByPath (splitString "." to); setFrom = setAttrByPath (splitString "." from); toOf = attrByPath (splitString "." to) @@ -22,13 +44,16 @@ let in [{ options = setFrom (mkOption { - description = "${fromStatus.name} of ."; - apply = x: toOf config; + description = "${status.name} of ."; + apply = x: status.msg.use (toOf config); }); }] ++ [{ options = setTo (mkOption { - extraConfigs = map (def: def.value) (fromOf options).definitions; + extraConfigs = + let externalDefs = (fromOf options).definitions; in + if externalDefs == [] then [] + else map (def: def.value) (status.msg.define externalDefs); }); }];