From c6bee265edc24f8b2766418e8d88675d1cf7f30a Mon Sep 17 00:00:00 2001 From: Matthias Fischmann Date: Mon, 10 Jun 2024 15:08:55 +0200 Subject: [PATCH] Add weeder to local dev tool chain. --- Makefile | 6 +++++- nix/haskell-pins.nix | 10 ++++++++++ nix/wire-server.nix | 1 + weeder.toml | 6 ++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 weeder.toml diff --git a/Makefile b/Makefile index dacc5c883b4..f41ee14ca87 100644 --- a/Makefile +++ b/Makefile @@ -151,7 +151,11 @@ ghcid: # Used by CI .PHONY: lint-all -lint-all: formatc hlint-check-all check-local-nix-derivations treefmt-check +lint-all: formatc hlint-check-all check-local-nix-derivations treefmt-check # weeder (does not work on CI yet) + +.PHONY: weeder +weeder: + time weeder -N || echo -e '\n\n*** make sure you have added this to your cabal.project.local and make clean before building wire-server:\n\npackage *\n ghc-options: -fwrite-ide-info\n\n' .PHONY: hlint-check-all hlint-check-all: diff --git a/nix/haskell-pins.nix b/nix/haskell-pins.nix index 39b77216b17..366be88689c 100644 --- a/nix/haskell-pins.nix +++ b/nix/haskell-pins.nix @@ -266,6 +266,16 @@ let "warp" = "warp"; }; }; + + # https://github.com/ocharles/weeder/pull/165 + weeder = { + src = pkgs.fetchFromGitHub { + owner = "fisx"; + repo = "weeder"; + rev = "027571e39a25aa0cfa6a7c7effcb868757527a2c"; + hash = "sha256-E35PVxi/4iJFfWts3td52KKZKQt4dj9KFP3SvWG77Cc="; + }; + }; }; hackagePins = { # Major re-write upstream, we should get rid of this dependency rather than diff --git a/nix/wire-server.nix b/nix/wire-server.nix index 781e29b69ba..eb167f38d68 100644 --- a/nix/wire-server.nix +++ b/nix/wire-server.nix @@ -420,6 +420,7 @@ let pkgs.cfssl pkgs.awscli2 (hlib.justStaticExecutables pkgs.haskellPackages.cabal-fmt) + (hlib.justStaticExecutables pkgs.haskellPackages.weeder) ] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [ pkgs.skopeo ]; diff --git a/weeder.toml b/weeder.toml new file mode 100644 index 00000000000..2739266cfad --- /dev/null +++ b/weeder.toml @@ -0,0 +1,6 @@ +# weeder intro and further reading: https://github.com/ocharles/weeder?tab=readme-ov-file#weeder +roots = ["^Main.main$", "^Paths_.*\\..*"] +type-class-roots = true # `root-instances` is more precise, but requires more config maintenance. + +# TODO: unused-types = true +# TODO: type-class-roots = false, and see how bad it gets