oppiliappan / statix

lints and suggestions for the nix programming language
https://git.peppe.rs/languages/statix/about
MIT License
579 stars 21 forks source link

Argument `--config` ignores config if its named differently than `statix.toml`. #71

Open soupglasses opened 1 year ago

soupglasses commented 1 year ago

When using --config to configure statix, it will silently ignore the config file completely if it is inside of the /nix/store. See the example below:

% cat statix.toml 
disabled = [
  "manual_inherit",
  "manual_inherit_from",
]

% cat /nix/store/xrkisfnii1d0q4bavmync17949c8v8q1-statix.toml
disabled = [
  "manual_inherit",
  "manual_inherit_from",
]

% statix check --config ./statix.toml sops.nix
[bin/src/config.rs:79] [self.ignore.as_slice(), extra_ignores].concat() = []

% statix check --config /nix/store/xrkisfnii1d0q4bavmync17949c8v8q1-statix.toml sops.nix
[bin/src/config.rs:79] [self.ignore.as_slice(), extra_ignores].concat() = []
[W04] Warning: Assignment instead of inherit from
   ╭─[sops.nix:7:3]
   │
 7 │   users = (fromJSON (readFile ./state/users.json)).users;
   ·   ───────────────────────────┬───────────────────────────  
   ·                              ╰───────────────────────────── This assignment is better written with inherit
───╯

% statix --version
statix 0.5.6
kip93 commented 1 year ago

Also came across this. Tried putting it into a temp file, changing permissions/ownership of the temp file, and other random stabs in the dark.

What fixed it for me is having the file be called exactly statix.toml. So, instead of using writeText "statix.toml" "..." I had to use writeTextDir "statix.toml" "...".

kip93 commented 1 year ago

This is consistent with paths outside of the nix store. If I do statix check -c ./foo.toml, it also gets ignored.