Skip to content

modules/keymap: improve lua deprecation#2035

Merged
MattSturgeon merged 1 commit intonix-community:mainfrom
MattSturgeon:lua_deprecation
Aug 18, 2024
Merged

modules/keymap: improve lua deprecation#2035
MattSturgeon merged 1 commit intonix-community:mainfrom
MattSturgeon:lua_deprecation

Conversation

@MattSturgeon
Copy link
Copy Markdown
Member

@MattSturgeon MattSturgeon commented Aug 17, 2024

  • Replace nullable lua option with a no-default option.
  • Made it so the deprecated option is only declared when lua = true is passed.
  • Replace normalizeMappings with a removeDeprecatedMapAttrs helper.
  • Added warnings for all options that historically had lua support.

This supersedes and closes #1795

Removing the attr from the final value

I'd like to do something like this directly in mkMapOptionSubmodule, however it doesn't seem to do what you'd expect...

type // {
  merge = loc: defs: builtins.removeAttrs (type.merge loc defs) [ "lua" ];
};

Therefore I've instead added apply functions to each keymap option that removes the lua attr.

See this message on matrix.

Showing the warning for all uses

Previously, we only checked the keymaps option in our deprecation warning.

We could instead have a lib.warn in the action's apply function when we call mkRaw, however this wouldn't have access to loc or defs to print a proper warning.

If overriding the merge function worked correctly, we could do it there, however I think this is fine for this PR, we can always improve things further in future work.

For now, modules/keymaps.nix is responsible for showing warnings for all options that previously had a lua sub-option.

@MattSturgeon MattSturgeon requested a review from a team August 17, 2024 23:51
@MattSturgeon

This comment was marked as off-topic.

@khaneliman

This comment was marked as off-topic.

Copy link
Copy Markdown
Contributor

@khaneliman khaneliman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels weird that the merge would be completely ignored, resulting in needing to apply in every consumer of a function. But, in lieu of a better alternative it makes sense to me, for now.

With the conversation around #1935 will this be another place we have a migration away from recommending __raw

@MattSturgeon
Copy link
Copy Markdown
Member Author

Feels weird that the merge would be completely ignored

I don't fully understand it either, we had the same issue implementing transitionType, which you'd expect could just override coercedTo's merge function.

My best guess is something in mkOptionType is using the merge passed to it, rather than the merge in the final attrs... Maybe this is something that could be resolved in nixpkgs?

@MattSturgeon

This comment was marked as outdated.

@mergify

This comment was marked as outdated.

@MattSturgeon

This comment was marked as outdated.

@mergify

This comment was marked as outdated.

- Replace nullable lua option with a no-default option.
- Made it so the deprecated option is only declared when `lua = true` is passed.
- Replace `normalizeMappings` with a `removeDeprecatedMapAttrs` helper.
- Added warnings for all options that historically had `lua` support.
@MattSturgeon

This comment was marked as outdated.

@mergify

This comment was marked as outdated.

@MattSturgeon MattSturgeon merged commit 7fb1f9d into nix-community:main Aug 18, 2024
@MattSturgeon MattSturgeon deleted the lua_deprecation branch August 18, 2024 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants