From 0eb939a2b1a2886f9d52f3bd764614f43330e96a Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 25 Jul 2022 17:22:41 -0400 Subject: Run deadnix as a linter --- Biz/Bild.nix | 6 +++--- Biz/Bild/Deps.nix | 4 ++-- Biz/Bild/Deps/inspekt3d.nix | 1 - Biz/Bot.nix | 4 ++-- Biz/Cloud/Git.nix | 2 +- Biz/Cloud/Grocy.nix | 2 +- Biz/Cloud/Web.nix | 2 +- Biz/Cloud/Znc.nix | 2 +- Biz/Dev/Hardware.nix | 2 +- Biz/Dev/Hoogle.nix | 2 +- Biz/Dev/Networking.nix | 2 +- Biz/Dev/Wireguard.nix | 2 +- Biz/Lint.hs | 14 ++++++++++++-- Biz/Nixpert.nix | 1 - Biz/Que/Host.nix | 1 - 15 files changed, 27 insertions(+), 20 deletions(-) (limited to 'Biz') diff --git a/Biz/Bild.nix b/Biz/Bild.nix index e7aaf7f..ad56549 100644 --- a/Biz/Bild.nix +++ b/Biz/Bild.nix @@ -112,10 +112,10 @@ rec { installPhase = "exit 0"; } // { env = ghc; }; - env = nixpkgs.pkgs.mkShell { + env = let linters = with nixpkgs.pkgs; [ ormolu hlint deadnix ]; in nixpkgs.pkgs.mkShell { name = "bizdev"; # this should just be dev tools - buildInputs = with nixpkgs.pkgs; [ + buildInputs = with nixpkgs.pkgs; linters ++ [ gcc bild ctags @@ -131,7 +131,7 @@ rec { ]; }; - os = cfg: (nixpkgs.nixos (args: cfg)).toplevel; + os = cfg: (nixpkgs.nixos (_args: cfg)).toplevel; pkgs = { inherit (nixpkgs) git; }; diff --git a/Biz/Bild/Deps.nix b/Biz/Bild/Deps.nix index 79f7ac3..c236a0c 100644 --- a/Biz/Bild/Deps.nix +++ b/Biz/Bild/Deps.nix @@ -1,4 +1,4 @@ -self: super: +_self: super: with import ./Constants.nix; let @@ -10,7 +10,7 @@ in rec { haskell = super.haskell // { packages = super.haskell.packages // { - "${ghcCompiler}" = super.haskell.packages."${ghcCompiler}".override (old: { + "${ghcCompiler}" = super.haskell.packages."${ghcCompiler}".override (_old: { overrides = with super.pkgs.haskell.lib; sel: sup: super.overridePinnedDeps (buildCabal sel) // { acid-state = dontCheck sup.acid-state; # mac: "too many open files" diff --git a/Biz/Bild/Deps/inspekt3d.nix b/Biz/Bild/Deps/inspekt3d.nix index 1093165..78393ee 100644 --- a/Biz/Bild/Deps/inspekt3d.nix +++ b/Biz/Bild/Deps/inspekt3d.nix @@ -1,6 +1,5 @@ { stdenv , lib -, fetchFromGitHub , autoreconfHook , pkgconfig , guile diff --git a/Biz/Bot.nix b/Biz/Bot.nix index f09279b..afd5eb4 100644 --- a/Biz/Bot.nix +++ b/Biz/Bot.nix @@ -30,7 +30,7 @@ in }; config = lib.mkIf cfg.enable { systemd.services = { - bizbot-${cfg.server}-${cfg.channel}-ii = { + "bizbot-${cfg.server}-${cfg.channel}-ii" = { wantedBy = [ "multi-user.target" ]; path = [ pkgs.ii ]; script = '' @@ -44,7 +44,7 @@ in ''; }; - bizbot-${cfg.server}-${cfg.channel} = { + "bizbot-${cfg.server}-${cfg.channel}" = { path = [ cfg.package ]; wantedBy = [ "multi-user.target" ]; after = [ "bizbot-${cfg.server}-${cfg.channel}-ii.service" ]; diff --git a/Biz/Cloud/Git.nix b/Biz/Cloud/Git.nix index d1cdf9f..a75fa82 100644 --- a/Biz/Cloud/Git.nix +++ b/Biz/Cloud/Git.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, config, ... }: +{ lib, config, ... }: let inherit (config.networking) domain; diff --git a/Biz/Cloud/Grocy.nix b/Biz/Cloud/Grocy.nix index 3f63cc7..697c2f1 100644 --- a/Biz/Cloud/Grocy.nix +++ b/Biz/Cloud/Grocy.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ ... }: { services.grocy = { diff --git a/Biz/Cloud/Web.nix b/Biz/Cloud/Web.nix index 3c7acea..a096779 100644 --- a/Biz/Cloud/Web.nix +++ b/Biz/Cloud/Web.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, ... }: let rootDomain = config.networking.domain; diff --git a/Biz/Cloud/Znc.nix b/Biz/Cloud/Znc.nix index 5ec4e56..79eee95 100644 --- a/Biz/Cloud/Znc.nix +++ b/Biz/Cloud/Znc.nix @@ -6,7 +6,7 @@ N.B.: generate znc passwords with 'nix-shell -p znc --command "znc --makepass"' */ -{ pkgs, lib, ... }: +{ pkgs, ... }: { services = { diff --git a/Biz/Dev/Hardware.nix b/Biz/Dev/Hardware.nix index dc5b573..eaf1bd9 100644 --- a/Biz/Dev/Hardware.nix +++ b/Biz/Dev/Hardware.nix @@ -1,7 +1,7 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: +{ lib, modulesPath, ... }: { imports = diff --git a/Biz/Dev/Hoogle.nix b/Biz/Dev/Hoogle.nix index 13a5bda..02330b5 100644 --- a/Biz/Dev/Hoogle.nix +++ b/Biz/Dev/Hoogle.nix @@ -25,7 +25,7 @@ in { }; packages = mkOption { - default = hp: []; + default = _hp: []; defaultText = "hp: []"; example = "hp: with hp; [ text lens ]"; description = '' diff --git a/Biz/Dev/Networking.nix b/Biz/Dev/Networking.nix index 150b098..88ec4fb 100644 --- a/Biz/Dev/Networking.nix +++ b/Biz/Dev/Networking.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ ... }: let ports = import ../Cloud/Ports.nix; diff --git a/Biz/Dev/Wireguard.nix b/Biz/Dev/Wireguard.nix index 5703f3d..9c72dd4 100644 --- a/Biz/Dev/Wireguard.nix +++ b/Biz/Dev/Wireguard.nix @@ -1,4 +1,4 @@ -{ lib, config, pkgs, ... }: +{ lib, pkgs, ... }: /* Wireguard VPN server diff --git a/Biz/Lint.hs b/Biz/Lint.hs index 8dafcb3..80e2665 100644 --- a/Biz/Lint.hs +++ b/Biz/Lint.hs @@ -131,6 +131,16 @@ pylint = fixArgs = Nothing } +deadnix :: Linter +deadnix = + Linter + { exe = "deadnix", + checkArgs = "--fail" : commonArgs, + fixArgs = Just <| "--edit" : commonArgs + } + where + commonArgs = ["--no-underscore", "--no-lambda-pattern-names"] + shellcheck :: Linter shellcheck = Linter {exe = "shellcheck", checkArgs = [], fixArgs = Nothing} @@ -159,9 +169,9 @@ runOne mode root cwd path_ = results +> traverse_ printResult >> results [ lint mode ormolu path_, lint mode hlint path_ ] - Just (Namespace _ Py) -> [] -- [lint mode pylint path_] + Just (Namespace _ Py) -> [pure <| NoOp path_] Just (Namespace _ Sh) -> [lint mode shellcheck path_] - Just (Namespace _ Nix) -> [pure <| NoOp path_] + Just (Namespace _ Nix) -> [lint mode deadnix path_] Just (Namespace _ Scm) -> [pure <| NoOp path_] Just _ -> [pure <. Warn <| "no linter for " <> Text.pack path_] diff --git a/Biz/Nixpert.nix b/Biz/Nixpert.nix index 51c6e66..6e9d392 100644 --- a/Biz/Nixpert.nix +++ b/Biz/Nixpert.nix @@ -14,7 +14,6 @@ let ${./Nixpert.md} \ > $out/index.html ''; - ports = import ../Cloud/Ports.nix; ssl = { cert = "/var/lib/acme/simatime.com/fullchain.pem"; key = "/var/lib/acme/simatime.com/key.pem"; diff --git a/Biz/Que/Host.nix b/Biz/Que/Host.nix index db2f748..84bd9cc 100644 --- a/Biz/Que/Host.nix +++ b/Biz/Que/Host.nix @@ -1,7 +1,6 @@ { options , lib , config -, pkgs , ... }: -- cgit v1.2.3