Lints and suggestions for the Nix programming language
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add `ignore` to statix.toml

Akshay 53b454cd 448e6f20

+43 -12
+1 -1
Cargo.lock
··· 588 588 589 589 [[package]] 590 590 name = "statix" 591 - version = "0.5.4" 591 + version = "0.5.5" 592 592 dependencies = [ 593 593 "ariadne", 594 594 "clap",
+1 -1
Cargo.toml
··· 4 4 "bin", 5 5 "lib", 6 6 "macros", 7 - "vfs" 7 + "vfs", 8 8 ] 9 9
+1 -1
bin/Cargo.toml
··· 1 1 [package] 2 2 name = "statix" 3 - version = "0.5.4" 3 + version = "0.5.5" 4 4 edition = "2018" 5 5 license = "MIT" 6 6 authors = [ "Akshay <nerdy@peppe.rs>" ]
+16 -6
bin/src/config.rs
··· 65 65 } 66 66 67 67 impl Check { 68 - pub fn vfs(&self) -> Result<ReadOnlyVfs, ConfigErr> { 68 + pub fn vfs(&self, extra_ignores: &[String]) -> Result<ReadOnlyVfs, ConfigErr> { 69 69 if self.streaming { 70 70 use std::io::{self, BufRead}; 71 71 let src = io::stdin() ··· 76 76 .join("\n"); 77 77 Ok(ReadOnlyVfs::singleton("<stdin>", src.as_bytes())) 78 78 } else { 79 - let ignore = dirs::build_ignore_set(&self.ignore, &self.target, self.unrestricted)?; 79 + let all_ignores = dbg!([self.ignore.as_slice(), extra_ignores].concat()); 80 + let ignore = dirs::build_ignore_set(&all_ignores, &self.target, self.unrestricted)?; 80 81 let files = dirs::walk_nix_files(ignore, &self.target)?; 81 82 vfs(files.collect::<Vec<_>>()) 82 83 } ··· 117 118 } 118 119 119 120 impl Fix { 120 - pub fn vfs(&self) -> Result<ReadOnlyVfs, ConfigErr> { 121 + pub fn vfs(&self, extra_ignores: &[String]) -> Result<ReadOnlyVfs, ConfigErr> { 121 122 if self.streaming { 122 123 use std::io::{self, BufRead}; 123 124 let src = io::stdin() ··· 128 129 .join("\n"); 129 130 Ok(ReadOnlyVfs::singleton("<stdin>", src.as_bytes())) 130 131 } else { 131 - let ignore = dirs::build_ignore_set(&self.ignore, &self.target, self.unrestricted)?; 132 + let all_ignores = [self.ignore.as_slice(), extra_ignores].concat(); 133 + let ignore = dirs::build_ignore_set(&all_ignores, &self.target, self.unrestricted)?; 132 134 let files = dirs::walk_nix_files(ignore, &self.target)?; 133 135 vfs(files.collect::<Vec<_>>()) 134 136 } ··· 260 262 pub struct ConfFile { 261 263 #[serde(default = "Vec::new")] 262 264 disabled: Vec<String>, 265 + 263 266 nix_version: Option<String>, 267 + 268 + #[serde(default = "Vec::new")] 269 + pub ignore: Vec<String>, 264 270 } 265 271 266 272 impl Default for ConfFile { 267 273 fn default() -> Self { 268 - let disabled = vec![]; 269 - let nix_version = None; 274 + let disabled = Default::default(); 275 + let ignore = Default::default(); 276 + let nix_version = Default::default(); 270 277 Self { 271 278 disabled, 272 279 nix_version, 280 + ignore, 273 281 } 274 282 } 275 283 } ··· 298 306 let ideal_config = { 299 307 let disabled = vec![]; 300 308 let nix_version = Some(utils::default_nix_version()); 309 + let ignore = vec![".direnv".into()]; 301 310 Self { 302 311 disabled, 303 312 nix_version, 313 + ignore, 304 314 } 305 315 }; 306 316 toml::ser::to_string_pretty(&ideal_config).unwrap()
+1 -1
bin/src/fix.rs
··· 51 51 use similar::TextDiff; 52 52 53 53 pub fn all(fix_config: FixConfig) -> Result<(), StatixErr> { 54 - let vfs = fix_config.vfs()?; 55 54 let conf_file = ConfFile::discover(&fix_config.conf_path)?; 55 + let vfs = fix_config.vfs(conf_file.ignore.as_slice())?; 56 56 57 57 let lints = conf_file.lints(); 58 58 let version = conf_file.version()?;
+4 -2
bin/src/lint.rs
··· 53 53 use rayon::prelude::*; 54 54 55 55 pub fn main(check_config: CheckConfig) -> Result<(), StatixErr> { 56 - let vfs = check_config.vfs()?; 57 - let mut stdout = io::stdout(); 58 56 let conf_file = ConfFile::discover(&check_config.conf_path)?; 59 57 let lints = conf_file.lints(); 60 58 let version = conf_file.version()?; 61 59 let session = SessionInfo::from_version(version); 60 + 61 + let vfs = check_config.vfs(conf_file.ignore.as_slice())?; 62 + 63 + let mut stdout = io::stdout(); 62 64 let lint = |vfs_entry| lint_with(vfs_entry, &lints, &session); 63 65 let results = vfs 64 66 .par_iter()
+19
flake.nix
··· 108 108 RUST_BACKTRACE = 1; 109 109 }); 110 110 111 + 112 + apps = forAllSystems 113 + (system: 114 + let 115 + pkgs = nixpkgsFor."${system}"; 116 + cachix-push-script = pkgs.writeScriptBin "cachix-push" '' 117 + ${pkgs.nixUnstable}/bin/nix build --json \ 118 + | ${pkgs.jq}/bin/jq -r '.[].outputs | to_entries[].value' \ 119 + | ${pkgs.cachix}/bin/cachix push statix 120 + ''; 121 + in 122 + { 123 + cachix-push = { 124 + type = "app"; 125 + program = "${cachix-push-script}/bin/cachix-push"; 126 + }; 127 + } 128 + ); 129 + 111 130 }; 112 131 }