From c81a3d2383a9bfdc0cd07f3d973100012ebefad3 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Mon, 1 Jun 2026 12:41:11 -0500 Subject: [PATCH] helix: assert languages migration warning --- modules/programs/helix.nix | 33 +++++++---- tests/modules/programs/helix/default.nix | 1 + .../programs/helix/legacy-languages.nix | 57 +++++++++++++++++++ 3 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 tests/modules/programs/helix/legacy-languages.nix diff --git a/modules/programs/helix.nix b/modules/programs/helix.nix index 04d029d92..0af8509dd 100644 --- a/modules/programs/helix.nix +++ b/modules/programs/helix.nix @@ -1,6 +1,7 @@ { config, lib, + options, pkgs, ... }: @@ -85,17 +86,9 @@ in languages = mkOption { type = with types; - coercedTo (listOf tomlFormat.type) ( - language: - lib.warn '' - The syntax of programs.helix.languages has changed. - It now generates the whole languages.toml file instead of just the language array in that file. - - Use - programs.helix.languages = { language = ; } - instead. - '' { inherit language; } - ) (addCheck tomlFormat.type builtins.isAttrs); + coercedTo (listOf tomlFormat.type) (language: { inherit language; }) ( + addCheck tomlFormat.type builtins.isAttrs + ); default = { }; example = literalExpression '' { @@ -210,6 +203,24 @@ in }; config = mkIf cfg.enable { + warnings = lib.optional (lib.any builtins.isList options.programs.helix.languages.definitions) ( + lib.hm.deprecations.mkDeprecatedOptionValueWarning { + option = [ + "programs" + "helix" + "languages" + ]; + old = "a list"; + replacement = "`programs.helix.languages.language`"; + details = '' + This option now generates the whole languages.toml file instead of just the language array in that file. + + Use: + programs.helix.languages = { language = ; } + ''; + } + ); + home.packages = if cfg.extraPackages != [ ] then [ diff --git a/tests/modules/programs/helix/default.nix b/tests/modules/programs/helix/default.nix index 9838207e2..fb17b8296 100644 --- a/tests/modules/programs/helix/default.nix +++ b/tests/modules/programs/helix/default.nix @@ -1,4 +1,5 @@ { helix-example-settings = ./example-settings.nix; + helix-legacy-languages = ./legacy-languages.nix; helix-only-extraconfig = ./only-extraconfig.nix; } diff --git a/tests/modules/programs/helix/legacy-languages.nix b/tests/modules/programs/helix/legacy-languages.nix new file mode 100644 index 000000000..1013feec7 --- /dev/null +++ b/tests/modules/programs/helix/legacy-languages.nix @@ -0,0 +1,57 @@ +{ + config, + pkgs, + ... +}: + +{ + # Exercise merging legacy list definitions with new attrset definitions. + imports = [ + { + programs.helix.languages.language-server.nil = { + command = "nil"; + }; + } + ]; + + programs.helix = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@helix@"; }; + languages = [ + { + name = "rust"; + auto-format = false; + } + ]; + }; + + test.asserts.warnings.expected = [ + '' + Using `programs.helix.languages` as a list is deprecated and will be + removed in a future release. Please use `programs.helix.languages.language` instead. + + This option now generates the whole languages.toml file instead of just the language array in that file. + + Use: + programs.helix.languages = { language = ; } + + '' + ]; + + nmt.script = + let + expectedLanguages = pkgs.writeText "helix-languages.expected.toml" '' + [[language]] + auto-format = false + name = "rust" + + [language-server.nil] + command = "nil" + ''; + in + '' + assertFileContent \ + home-files/.config/helix/languages.toml \ + ${expectedLanguages} + ''; +}