Synthetica9 / nix-linter

Linter for the Nix expression language
BSD 3-Clause "New" or "Revised" License
158 stars 16 forks source link

False postive UnneededRec with nested attribute sets #43

Open nothingelsematters opened 3 years ago

nothingelsematters commented 3 years ago

Example:

rec {
  a = {
    a-b = "a - b";
  };
  c = {
    c-d = a.a-b;
  };
}

It is treated as unneeded rec now

I need this rec here, because otherwise it results in:
undefined variable 'a' at ...

avdv commented 2 years ago

Here is another example which triggers this false positive:

rec {
  defaultApp = 1;
  apps.default = defaultApp;

  devShell =  2;
  devShells.default = devShell;
}

results in Unneeded 'rec' on set at fp.nix:1:1-7:2.

Interestingly, if one comments out either the apps.default or devShells.default line the error is gone.