Skip to content

Search for default statix.toml according to xdg spec#2666

Open
MrQubo wants to merge 3 commits into
molybdenumsoftware:masterfrom
MrQubo:statix-toml-xdg-spec
Open

Search for default statix.toml according to xdg spec#2666
MrQubo wants to merge 3 commits into
molybdenumsoftware:masterfrom
MrQubo:statix-toml-xdg-spec

Conversation

@MrQubo

@MrQubo MrQubo commented Jun 12, 2026

Copy link
Copy Markdown

Comment thread readme.md
`$XDG_CONFIG_HOME/statix/statix.toml`. Alternatively, you
can pass the path to the `statix.toml` file on the command
line with the `--config` flag (available on `statix check`,
`statix fix`, and `statix single`).

@MrQubo MrQubo Jun 12, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I noticed that the list of subcommands, where --config flag is available, is incomplete.

@mightyiam

Copy link
Copy Markdown
Member

Thank you for this contribution! Don't you think statix is a project-specific tool?

@MrQubo

MrQubo commented Jun 13, 2026

Copy link
Copy Markdown
Author

Thank you for this contribution! Don't you think statix is a project-specific tool?

I think some of the warnings are useful to have when editing nix files. I configured my editor to run statix on every nix file and display warnings. But I wanted to disable one of the warnings. They way it works in this PR, statix will pick first statix.toml it tries, so any project-specific statix.toml would be used instead of user-configured one.

@mightyiam

Copy link
Copy Markdown
Member

I want you to have what you want. Just trying make sure things land correctly.

Wouldn't some would claim that this is impure behavior because their linter looks for a config file outside of their project dir?

@MrQubo

MrQubo commented Jun 14, 2026

Copy link
Copy Markdown
Author

As it is currently statix already looks for statix.toml in your home folder and root directory if the project doesn't have it's own statix.toml. If someone creates a project and want to ensure that statix runs the same on every developers machine, they should put a statix.toml in the root of their project (even if it's empty file), or by explicitly calling statix with --config arg in project's tooling scripts.

The way I see it, is that this PR let's you change the default settings of statix for every project and file that doesn't have statix.toml.

@mightyiam mightyiam left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Okay, I agree.

Would you be willing to contribute a test for existing behavior of reading a config file, prior to this behavior change?

Comment thread bin/src/config.rs Outdated
@MrQubo MrQubo force-pushed the statix-toml-xdg-spec branch from 6c3fd07 to d9c52d2 Compare June 15, 2026 09:20
@MrQubo

MrQubo commented Jun 16, 2026

Copy link
Copy Markdown
Author

Would you be willing to contribute a test for existing behavior of reading a config file, prior to this behavior change?

I never wrote filesystem integration tests like that, is there some example of that in the repo?

@MrQubo

MrQubo commented Jun 16, 2026

Copy link
Copy Markdown
Author

I also modified statix dump to print user's statix.toml from xdg config.
I think that makes sense from the UX perspective. User would put statix.toml in xdg config when he wants to change some default settings of statix. statix dump is used by the user when he wants to create a new project, so it's likely that the user might want to use his own defaults.

@mightyiam

Copy link
Copy Markdown
Member

Hrm... no, I don't think we have general integration test tooling here. Would you be interested in contributing the beginning of that? Perhaps some neat crate that provides a convenient API.

@MrQubo

MrQubo commented Jun 18, 2026

Copy link
Copy Markdown
Author

Would you be interested in contributing the beginning of that? Perhaps some neat crate that provides a convenient API.

No, not really.

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.

Add an option to globally disable rule

2 participants