oppiliappan / statix

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

False positive (or wrong fix ?) in flake.nix #42

Open maxice8 opened 2 years ago

maxice8 commented 2 years ago

I have the following in my flake.nix

  outputs = {...} @ inputs: import ./desktop/outputs.nix inputs;

running statix check flake.nix shows this:

[W11] Warning: Found redundant pattern bind in function argument
    ╭─[flake.nix:42:13]
    │
 42 │   outputs = {...} @ inputs: import ./desktop/outputs.nix inputs;
    ·             ───────┬──────
    ·                    ╰──────── This pattern bind is redundant, use inputs instead

running flake.nix generates the following fix:

diff --git a/flake.nix b/flake.nix
index 525ee35..3727018 100644
--- a/flake.nix
+++ b/flake.nix
@@ -39,5 +39,5 @@
     neovim-nightly.inputs.nixpkgs.follows = "nixpkgs";
   };

-  outputs = {...} @ inputs: import ./desktop/outputs.nix inputs;
+  outputs = import ./desktop/outputs.nix;
 }

but that causes flake check to fail:

$ flake check
error: expected a function but got a thunk at /nix/store/xxkl5h6wdr7w54kps7fdk0m5didg9gyf-source/flake.nix:42:3
oppiliappan commented 2 years ago

Ah, flake attributes such as inputsetc. are a little special cased. They are not allowed to perform any evaluations to produce the outputs attribute, for example. Currently statix does not understand flakes and their specs, we can probably fix this once it does.