From 3cd8d5cf6b46d5496f92f710b9060a023798a2fa Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Thu, 2 Feb 2023 09:53:59 -0500
Subject: [PATCH] Add a helper for running `hlint` via the flake.

---
 lib.nix | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/lib.nix b/lib.nix
index 28bf4a7..826d767 100644
--- a/lib.nix
+++ b/lib.nix
@@ -65,6 +65,25 @@ rec {
     ${packageName} = default;
   };
 
+  apps = {
+    # Create a program that runs hlint.
+    hlint = {
+      # An argv to pass to hlint in addition to any arguments passed on the
+      # `nix run` command line.
+      argv ? [ "src/" "test/" ]
+    }: {
+      type = "app";
+      program =
+        let
+          args = builtins.concatStringsSep " " argv;
+        in
+          "${pkgs.writeScript "hlint"
+            ''
+            ${hsPkgs.hlint}/bin/hlint ${args} "$@"
+            ''}";
+    };
+  };
+
   # haskellDevShell = { pkgs, system, haskellPackageName, src }:
   #   let
   #     hsPkgs' = hsPkgs {
-- 
GitLab