Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "i18n.inputMethod.enabled has a confusing type" #310708

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

importantblimp
Copy link
Contributor

@importantblimp importantblimp commented May 11, 2024

Description of changes

This commit introduces two new properties:
enable and type, to replace the enabled property.
enable has the same meaning as is common across nixpkgs.
type has the same meaning as the existing enabled property.
enabled property is now deprecated and will be removed in a future release.

Fixes #180654

I updated and ran the existing inputMethod tests:
nix-build -A nixosTests.fcitx5 -A nixosTests.installed-tests.ibus

Maintainers:
@ericsagnes

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@importantblimp
Copy link
Contributor Author

This is a breaking change for 24.05 (hence the documentation update).
I thought it simple enough to make in one go, but if this is the type of change that needs to be split up just let me know.

importantblimp added a commit to importantblimp/kime that referenced this pull request May 11, 2024
@honnip
Copy link
Contributor

honnip commented May 11, 2024

I think you meant enable rather than enabled for a bool property

@@ -28,8 +30,10 @@ in
{
options.i18n = {
inputMethod = {
enabled = mkOption {
type = types.nullOr (types.enum [ "ibus" "fcitx5" "nabi" "uim" "hime" "kime" ]);
enabled = mkEnableOption "an additional input method type";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
enabled = mkEnableOption "an additional input method type";
enable = mkEnableOption "an additional input method type";

for consistency with any other module.
Then we also add a mkRenamedOptionModule entry to imports

Also I'd adjust the defaults for the new options, for a smoother transition, i.e. set enable's default to enabled != null and type's default to enabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made both of these changes, but they seem to be mutually exclusive, and the two tests are now failing.

Am I just doing it wrong? I'd appreciate your guidance.

Test with new style config (nix-build -A nixosTests.installed-tests.ibus), where the error is in the module definition itself:

error:
       Failed assertions:
       - The option definition `i18n.inputMethod.enabled' in `/home/gy/src/nixpkgs/nixos/modules/i18n/input-method/default.nix' no longer has any effect; please remove it.
       Use <literal>i18n.inputMethod.type and .enable = true; instead<literal>

Test with old style config (nix-build -A nixosTests.fcitx5):

error: The option `i18n.inputMethod.enabled' can no longer be used since it's been removed. Use <literal>i18n.inputMethod.type and .enable = true; instead<literal>

Copy link
Member

Choose a reason for hiding this comment

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

You're right. We should not use mk(Removed|Renamed)OptionModule here.
Removing that fixes the tests.

What we could do (to ensure that users get a warning with .enabled) is to set config.warnings if .enabled != null.

@eclairevoyant eclairevoyant marked this pull request as draft May 11, 2024 04:03
@eclairevoyant
Copy link
Member

Drafting for now as breaking changes are frozen anyway due to the release (see #303285)

@importantblimp
Copy link
Contributor Author

Drafting for now as breaking changes are frozen anyway due to the release (see #303285)

I don't feel the need to rush this in, but if it is ready before the 15th: with your suggestions the change is no longer breaking so could be included in 24.05?

@eclairevoyant
Copy link
Member

Yes, if we're not breaking anything, I believe it could even be backported per https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#changes-acceptable-for-releases:

The release branches should generally only receive backwards-compatible changes, both for the Nix expressions and derivations.

@@ -11,7 +11,8 @@ On NixOS, you need to explicitly enable `ibus` with given engines before customi
```nix
{ pkgs, ... }: {
i18n.inputMethod = {
enabled = "ibus";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've intentionally left the other test (nixos/tests/fcitx5/default.nix, not present in this review) using enabled to have a test for the backwards compatibility of this change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, this is the docs file. I meant to add this to nixos/tests/installed-tests/ibus.nix

@@ -81,7 +82,8 @@ The following snippet can be used to configure Fcitx:
```nix
{
i18n.inputMethod = {
enabled = "fcitx5";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although I've updated the documentation for all of the input methods

This commit introduces two new properties:
`enable` and `type`, to replace the `enabled` property.
`enable` has the same meaning as is common across nixpkgs.
`type` has the same meaning as the existing `enabled` property.
`enabled` property is now deprecated and will be removed in a future release.

Fixes NixOS#180654
@importantblimp
Copy link
Contributor Author

@eclairevoyant this is ready to go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

i18n.inputMethod.enabled has a confusing type
4 participants