statix icon indicating copy to clipboard operation
statix copied to clipboard

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

Open soupglasses opened this issue 2 years ago • 2 comments

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

soupglasses avatar Feb 16 '23 09:02 soupglasses

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 avatar Sep 16 '23 08:09 kip93

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

kip93 avatar Sep 16 '23 08:09 kip93