Repository navigation
stylua: drop the stylua wrapper package - #9876
rachitvrma wants to merge 1 commit into
Conversation
khaneliman
left a comment
There was a problem hiding this comment.
Thanks for tracking this down. I reproduced it with StyLua 2.6.0: passing --search-parent-directories twice exits with an error, and conform.nvim passes the flag by default, so dropping the wrapper makes sense to me.
I left two requests inline, plus an optional suggestion for a news entry. Could you also change the commit subject prefix from module/stylua: to stylua:, to match the commit format?
| cfg.package; | ||
| in | ||
| { | ||
| meta.maintainers = [ lib.maintainers.rachitvrma ]; |
There was a problem hiding this comment.
issue (blocking): Removing finalPackage breaks configurations that read it. The option was hidden, but at least one public configuration adds config.programs.stylua.finalPackage to a package list, and with this change that fails with only error: attribute 'finalPackage' missing. I think we should keep the removal and declare it, so those users are told what to change, in line with the backward compatibility guideline:
| meta.maintainers = [ lib.maintainers.rachitvrma ]; | |
| meta.maintainers = [ lib.maintainers.rachitvrma ]; | |
| imports = [ | |
| (lib.mkRemovedOptionModule [ "programs" "stylua" "finalPackage" ] '' | |
| Home Manager no longer wraps StyLua. Use `programs.stylua.package` | |
| instead, and pass `--search-parent-directories` if the command should | |
| read the generated configuration file. | |
| '') | |
| ]; |
I tested this on top of your commit with a configuration that reads the old option. Evaluation still stops, but now with "The option programs.stylua.finalPackage' can no longer be used since it's been removed." followed by the text above. stylua-empty-configandstylua-example-config` still pass.
|
|
||
| options.programs.stylua = { | ||
| enable = mkEnableOption "stylua, a formatter for lua"; | ||
| package = mkPackageOption pkgs "stylua" { }; |
There was a problem hiding this comment.
issue: The new cfg.package != null check in home.packages can never be false, because this option still only accepts a package. Setting programs.stylua.package = null fails with "A definition for option programs.stylua.package' is not of type package'". Now that nothing wraps the package, the module works without installing StyLua, so I think making the option nullable is the right way to finish this:
| package = mkPackageOption pkgs "stylua" { }; | |
| package = mkPackageOption pkgs "stylua" { nullable = true; }; |
With this applied, I built a configuration that sets package = null together with settings: stylua.toml is still generated and StyLua is not added to home.packages.
| description = '' | ||
| Configuration options that are written to {file}`XDG_CONFIG_HOME/stylua/stylua.toml` | ||
| Configuration options that are written to {file}`XDG_CONFIG_HOME/stylua/stylua.toml`. | ||
| To use this configuration file pass the `--search-parent-directories` flag to `stylua`. |
There was a problem hiding this comment.
suggestion (non-blocking): This also changes behavior for people who already set settings and run stylua directly, or through a tool that does not add the flag. With StyLua 2.6.0 in a project without its own stylua.toml, stylua - ignores $XDG_CONFIG_HOME/stylua/stylua.toml and formats with the defaults. It only reads that file with --search-parent-directories. Nothing fails, so a rebuild will not tell them. Could we add a news entry for it? nix run .#create-news-entry creates the file, and this condition limits it to the affected users:
condition = config.programs.stylua.enable && config.programs.stylua.settings != { };I checked that this condition is true with settings set and false with the default empty settings.
Many formatters use default flags (for example `conform.nvim` uses the `--search-parent-directories` by default. Using the wrapper package, breaks it, since the flag is being passed twice). Instead of passing the flag in a wrapper, we provide the information on how to use it in the description.
97d87f2 to
21ceb8d
Compare
Description
Many formatters use default flags (for example
conform.nvimuses the--search-parent-directoriesby default. Using the wrapper package, breaks it, since the flag is being passed twice). Instead of passing the flag in a wrapper, we provide the information on how to use it in the description.Checklist
Change is backwards compatible.
Code formatted with
nix fmtornix-shell -A dev --run treefmt.Code tested through
nix build .#test-allor a targeted
nix run .#tests -- <pattern>.Test cases updated/added. See example.
Commit messages are formatted like
See CONTRIBUTING for more information and recent commit messages for examples.
If this PR adds a new module
If this PR adds an exciting new feature or contains a breaking change.