feat(wrapperModulers.stylua): init - #569
Open
kuppo wants to merge 13 commits into
Open
Conversation
MacaylaMarvelous81
approved these changes
Jul 1, 2026
MacaylaMarvelous81
left a comment
Contributor
There was a problem hiding this comment.
Works well! It's possible that users might want to use a different path than bin/cp_stylua_toml for the copy script, such as if they want to use a different name, so I suggest an option to easily customize that. Maybe something like cpScript.enable and cpScript.path?
I also think a check that tests the program functionality might be useful so that breakage from future changes are not silent.
Imperative test process
[jomarm@dell-inspiron7773:~/nix-wrapper-modules]$ echo "print 'ugly and bad but or and good'"
> test.lua
[jomarm@dell-inspiron7773:~/nix-wrapper-modules]$ nix-shell -p '(import ./. {}).wrappers.stylua.wrap { pkgs = import <nixpkgs> {}; customStyle = { call_parentheses = "None"; quote_style = "AutoPreferSingle"; }; }' --command 'stylua -c test.lua'
[jomarm@dell-inspiron7773:~/nix-wrapper-modules]$ echo $?
0
[jomarm@dell-inspiron7773:~/nix-wrapper-modules]$ nix-shell -p '(import ./. {}).wrappers.stylua.wrap { pkgs = import <nixpkgs> {}; }' --command 'stylua -c test.lua' Diff in test.lua:
1 |-print 'ugly and bad but or and good'
1 |+print("ugly and bad but or and good")
[jomarm@dell-inspiron7773:~/nix-wrapper-modules]$ nix-shell -p '(import ./. {}).wrappers.stylua.wrap { pkgs = import <nixpkgs> {}; customStyle = { call_parentheses = "None"; quote_style = "AutoPreferSingle"; }; generateCpScript = true; }' --command 'cp_stylua_toml' && cat stylua.toml
this derivation will be built:
/nix/store/imkcpm20j9sqmiqvac00p9gq8mkhcd6p-stylua-2.5.2.drv
building '/nix/store/imkcpm20j9sqmiqvac00p9gq8mkhcd6p-stylua-2.5.2.drv'...
/nix/store/8y5ars30x2axzqjwdhg2364sg9gb7kz5-stylua-2.5.2/bin:
stylua: File exists
Patching self-references in specified files...
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: buildPhase
Running phase: installPhase
block_newline_gaps = "Never"
call_parentheses = "None"
collapse_simple_statement = "Never"
column_width = 120
indent_type = "Tabs"
indent_width = 4
line_endings = "Unix"
quote_style = "AutoPreferSingle"
space_after_function_names = "Never"
syntax = "All"
[sort_requires]
enabled = false
added 7 commits
July 2, 2026 21:27
MacaylaMarvelous81
approved these changes
Jul 2, 2026
Author
|
That is a good advice and a good practice I should keep.
|
MacaylaMarvelous81
approved these changes
Jul 4, 2026
MacaylaMarvelous81
left a comment
Contributor
There was a problem hiding this comment.
Test run on x86_64-linux (success)
[jomarm@dell-inspiron7773:~/nix-wrapper-modules]$ nix-build --arg pkgs 'import <nixpkgs> {}' --arg self 'import ./. {}' --arg tlib '(import <nixpkgs> {}).callPackage ./ci/test-lib.nix { self = import ./. {}; }' wrapperModules/s/stylua/check.nix
these 6 derivations will be built:
/nix/store/jh5yw0g9zaq09n4z2d625jsm28v74nap-stylua-2.5.2.drv
/nix/store/knjrymdkj5kmq8mixai1l5i26ww9w18n-stylua-2.5.2.drv
/nix/store/l9ymi7gc05c3bpqbmdabfxy22phli3jw-stylua-2.5.2.drv
/nix/store/rjys6hz4y4fyriffvg01n0bsbifyfy25-stylua-2.5.2.drv
/nix/store/y0f336s8admwbm59fahcnnw1qyl9b06d-stylua-2.5.2.drv
/nix/store/hsmimpzv2d4k6cr9h28s93v3hpp6vjsb-stylua-test.drv
these 11 paths will be fetched (2.9 MiB download, 12.8 MiB unpacked):
/nix/store/l22fp7vhwvf6zvhk3mf7wmra6llb1pv7-python3.13-colorama-0.4.6
/nix/store/mclvsxxbggf9v0lh98jpw8n79apb56v8-python3.13-remarshal-1.3.0
/nix/store/7szlv37z4k1dz4b57h6hjkpv3rgxzbv1-python3.13-rich-argparse-1.7.2
/nix/store/grx6892wf0s7dw1kjx3librplg1cgw06-python3.13-ruamel-base-1.0.0
/nix/store/qa0cja0wgm7408k8z4bj84bx12scnpip-python3.13-ruamel-yaml-0.19.1
/nix/store/jmmdz0vkj4cphlyf6y7gdngm5hfhwisl-python3.13-ruamel-yaml-clib-0.2.15
/nix/store/07nsvnamhq2xpn0zixw2xbvizs43sj71-python3.13-tomli-2.4.0
/nix/store/rahjag01h0a9dmi3iljk7y60aal13iyq-python3.13-tomlkit-0.14.0
/nix/store/12gwm2lik7f59iyan5m7bh5ygpfv8664-python3.13-u-msgpack-python-2.8.0
/nix/store/pr27j8nm0xl52pq4ylncj9kwjw3b84mk-stdenv-linux
/nix/store/8y5ars30x2axzqjwdhg2364sg9gb7kz5-stylua-2.5.2
copying path '/nix/store/pr27j8nm0xl52pq4ylncj9kwjw3b84mk-stdenv-linux' from 'https://cache.nixos.org'...
copying path '/nix/store/8y5ars30x2axzqjwdhg2364sg9gb7kz5-stylua-2.5.2' from 'https://cache.nixos.org'...
copying path '/nix/store/rahjag01h0a9dmi3iljk7y60aal13iyq-python3.13-tomlkit-0.14.0' from 'https://cache.nixos.org'...
copying path '/nix/store/jmmdz0vkj4cphlyf6y7gdngm5hfhwisl-python3.13-ruamel-yaml-clib-0.2.15' from 'https://cache.nixos.org'...
copying path '/nix/store/l22fp7vhwvf6zvhk3mf7wmra6llb1pv7-python3.13-colorama-0.4.6' from 'https://cache.nixos.org'...
copying path '/nix/store/7szlv37z4k1dz4b57h6hjkpv3rgxzbv1-python3.13-rich-argparse-1.7.2' from 'https://cache.nixos.org'...
copying path '/nix/store/07nsvnamhq2xpn0zixw2xbvizs43sj71-python3.13-tomli-2.4.0' from 'https://cache.nixos.org'...
copying path '/nix/store/12gwm2lik7f59iyan5m7bh5ygpfv8664-python3.13-u-msgpack-python-2.8.0' from 'https://cache.nixos.org'...
copying path '/nix/store/grx6892wf0s7dw1kjx3librplg1cgw06-python3.13-ruamel-base-1.0.0' from 'https://cache.nixos.org'...
copying path '/nix/store/qa0cja0wgm7408k8z4bj84bx12scnpip-python3.13-ruamel-yaml-0.19.1' from 'https://cache.nixos.org'...
copying path '/nix/store/mclvsxxbggf9v0lh98jpw8n79apb56v8-python3.13-remarshal-1.3.0' from 'https://cache.nixos.org'...
building '/nix/store/jh5yw0g9zaq09n4z2d625jsm28v74nap-stylua-2.5.2.drv'...
building '/nix/store/knjrymdkj5kmq8mixai1l5i26ww9w18n-stylua-2.5.2.drv'...
building '/nix/store/l9ymi7gc05c3bpqbmdabfxy22phli3jw-stylua-2.5.2.drv'...
building '/nix/store/rjys6hz4y4fyriffvg01n0bsbifyfy25-stylua-2.5.2.drv'...
building '/nix/store/y0f336s8admwbm59fahcnnw1qyl9b06d-stylua-2.5.2.drv'...
/nix/store/8y5ars30x2axzqjwdhg2364sg9gb7kz5-stylua-2.5.2/bin:
stylua: File exists
Patching self-references in specified files...
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: buildPhase
Running phase: installPhase
/nix/store/8y5ars30x2axzqjwdhg2364sg9gb7kz5-stylua-2.5.2/bin:
stylua: File exists
Patching self-references in specified files...
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: buildPhase
Running phase: installPhase
/nix/store/8y5ars30x2axzqjwdhg2364sg9gb7kz5-stylua-2.5.2/bin:
stylua: File exists
Patching self-references in specified files...
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: buildPhase
Running phase: installPhase
/nix/store/8y5ars30x2axzqjwdhg2364sg9gb7kz5-stylua-2.5.2/bin:
stylua: File exists
Patching self-references in specified files...
Running phase: updateAutotoolsGnuConfigScriptsPhase
/nix/store/8y5ars30x2axzqjwdhg2364sg9gb7kz5-stylua-2.5.2/bin:
stylua: File exists
Patching self-references in specified files...
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: buildPhase
Running phase: buildPhase
Running phase: installPhase
Running phase: installPhase
building '/nix/store/hsmimpzv2d4k6cr9h28s93v3hpp6vjsb-stylua-test.drv'...
call_parentheses = "None"
column_width = 100
quote_style = "ForceSingle"
You have not generated stylua.toml. You can use -i|--add-doc option to add a stylua.toml with only documentation included.
# Enable requires sorting [enabled = true|false]
quote_style = "ForceSingle"
cp_stylua_toml [-h|--help|-i|--add-doc]
-i|--add-doc Add the configuration doccumentation to the end of the stylua.toml
cp_stylua_toml [-h|--help|-i|--add-doc]
-i|--add-doc Add the configuration doccumentation to the end of the stylua.toml
# Enable requires sorting [enabled = true|false]
# Enable requires sorting [enabled = true|false]
/nix/store/n4vwp561brcbbcka1zg8c45ccdr1dccl-stylua-test
This looks good. Thanks for working with me!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR add a wrapper for stylua.
It mainly used to configure the style of the stylua. You can add nix expression of the configuration and it will generate the stylua.toml file for you. Additionally, you can enable the wrapper to generate a copy script which copy the generated configuration file into CWD in case people want to customize individual style or want to include it into the repo.