Skip to content

Commit 1957b26

Browse files
committed
lib/deprecation: add processRenameOptions
Supports a function that can be used to specify the destination path for a list of options.
1 parent bc5733a commit 1957b26

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/deprecation.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ rec {
4646
'';
4747
};
4848

49+
processRenameOptions =
50+
options: oldPath: newPath:
51+
(map (
52+
option:
53+
let
54+
result =
55+
let
56+
optionPath = lib.toList option;
57+
optionPathSnakeCase = map lib.nixvim.toSnakeCase optionPath;
58+
in
59+
lib.mkRenamedOptionModule (oldPath ++ optionPath) (newPath ++ optionPathSnakeCase);
60+
in
61+
result
62+
) options);
63+
4964
# A clone of types.coercedTo, but it prints a warning when oldType is used.
5065
transitionType =
5166
oldType: coerceFn: newType:

lib/helpers.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ let
3838
byteCompileLuaDrv
3939
;
4040

41-
inherit (helpers.deprecation) getOptionRecursive mkDeprecatedSubOptionModule transitionType;
41+
inherit (helpers.deprecation)
42+
getOptionRecursive
43+
mkDeprecatedSubOptionModule
44+
processRenameOptions
45+
transitionType
46+
;
4247

4348
inherit (helpers.options)
4449
defaultNullOpts

0 commit comments

Comments
 (0)