jtojnar / nixpkgs-hammering

Beat your package expressions into a shape
MIT License
245 stars 14 forks source link

Attribute ordering has lots of false alarms #8

Closed SuperSandro2000 closed 3 years ago

SuperSandro2000 commented 3 years ago

I run nixpkgs-hammering on https://github.com/NixOS/nixpkgs/pull/105669/files#diff-ab1e40bce9916c4544e104a80eb597d731be5c0cade896697f8b925d6960eaecR15 and got the following warnings:

trace: warning: `installPhase` should probably contain `runHook preInstall` and `runHook postInstall`.
See: https://github.com/jtojnar/nixpkgs-hammering/blob/master/explanations/missing-phase-hooks.md
trace: warning: It is a good idea to avoid overriding `buildPhase` when possible.
See: https://github.com/jtojnar/nixpkgs-hammering/blob/master/explanations/explicit-phases.md
It is a good idea to avoid overriding `installPhase` when possible.
See: https://github.com/jtojnar/nixpkgs-hammering/blob/master/explanations/explicit-phases.md
trace: warning: The attribute “src” should preferably come before “name” attribute in the expression.
See: https://github.com/jtojnar/nixpkgs-hammering/blob/master/explanations/attribute-ordering.md
The attribute “meta” should preferably come before lists of dependencies’ “nativeBuildInputs” attribute in the expression.
See: https://github.com/jtojnar/nixpkgs-hammering/blob/master/explanations/attribute-ordering.md

but the package looks like

buildBazelPackage rec {
  name = "bazel-watcher-${version}";
  version = "0.13.1";
  version = "0.14.0";

  src = fetchFromGitHub {
    owner = "bazelbuild";
    repo = "bazel-watcher";
    rev = "v${version}";
    sha256 = "0n28q27510ymg5d455hrbk7z8wawszgjmqjjhb4zximqhvxks7kh";
    sha256 = "0gigl1lg8sb4bj5crvj54329ws4yirldbncs15f96db6vhp0ig7r";
  };

Does it maybe look into buildBazelPackage and name is there before source?

jtojnar commented 3 years ago

Yeah, it works on mkDerivation level. I guess we should override all buildFooPackage functions the same way and only apply the checks to the topmost function.

jtojnar commented 3 years ago

As a first step, I started printing relevant code location in c25766c9d241469f8e827303a8e10ed500721d2d.

SuperSandro2000 commented 3 years ago

So far it works great and yields a lot less of false positives.