From 6ee58c0d259c6eebe5e62e6211c1b7c7d377e6a9 Mon Sep 17 00:00:00 2001 From: Daniel Firth Date: Wed, 14 Feb 2024 09:49:40 +0000 Subject: [PATCH] Replace hlint shell job with check derivation. --- .github/workflows/formatting.yaml | 2 +- flake.lock | 38 +++++++++++++++++++++++++++++++ flake.nix | 13 ++++++++++- nix/hydra/shell.nix | 6 ++--- 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/.github/workflows/formatting.yaml b/.github/workflows/formatting.yaml index 2af62a4951d..025bf949257 100644 --- a/.github/workflows/formatting.yaml +++ b/.github/workflows/formatting.yaml @@ -30,4 +30,4 @@ jobs: - name: 📐 Check hlint run: | - nix develop .#fmt --command hlint . + nix build .#checks.x86_64-linux.hlint diff --git a/flake.lock b/flake.lock index db27a0dc816..c36941b8467 100644 --- a/flake.lock +++ b/flake.lock @@ -791,6 +791,21 @@ "type": "github" } }, + "flake-utils_8": { + "locked": { + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "ghc-8.6.5-iohk": { "flake": false, "locked": { @@ -1498,6 +1513,28 @@ "url": "https://gitlab.haskell.org/hamishmack/iserv-proxy.git" } }, + "lint-utils": { + "inputs": { + "flake-utils": "flake-utils_8", + "nixpkgs": [ + "haskellNix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1707777931, + "narHash": "sha256-PsPb5xMBZ9dPDP04o9vqKEUIEG80Z84/74fPuOMs0ZI=", + "owner": "homotopic", + "repo": "lint-utils", + "rev": "5f11e3e51d8f1aa4ed62a89e90f05953931e105a", + "type": "github" + }, + "original": { + "owner": "homotopic", + "repo": "lint-utils", + "type": "github" + } + }, "lowdown-src": { "flake": false, "locked": { @@ -2550,6 +2587,7 @@ "haskellNix": "haskellNix_2", "hls": "hls", "iohk-nix": "iohk-nix", + "lint-utils": "lint-utils", "mithril": "mithril", "nixpkgs": [ "haskellNix", diff --git a/flake.nix b/flake.nix index 5ff471df347..8393389d7c7 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,10 @@ haskellNix.url = "github:input-output-hk/haskell.nix"; iohk-nix.url = "github:input-output-hk/iohk-nix"; flake-utils.url = "github:numtide/flake-utils"; + lint-utils = { + url = "github:homotopic/lint-utils"; + inputs.nixpkgs.follows = "haskellNix/nixpkgs"; + }; CHaP = { url = "github:input-output-hk/cardano-haskell-packages?ref=repo"; flake = false; @@ -33,6 +37,9 @@ (system: let pkgs = import inputs.nixpkgs { inherit system; }; + tools = { + hlint = hydraProject.pkgs.haskell-nix.tool hydraProject.compiler "hlint" "3.8"; + }; hydraProject = import ./nix/hydra/project.nix { inherit (inputs) haskellNix iohk-nix CHaP; inherit system nixpkgs; @@ -58,8 +65,12 @@ spec = import ./spec { inherit pkgs; }; }; + checks = let lu = inputs.lint-utils.linters.${system}; in { + hlint = lu.hlint { src = self; hlint = tools.hlint; }; + }; + devShells = (import ./nix/hydra/shell.nix { - inherit inputs hydraProject system; + inherit inputs hydraProject tools system; }) // { ci = (import ./nix/hydra/shell.nix { inherit inputs hydraProject system; diff --git a/nix/hydra/shell.nix b/nix/hydra/shell.nix index ffa692fc252..322e90a5eec 100644 --- a/nix/hydra/shell.nix +++ b/nix/hydra/shell.nix @@ -7,6 +7,7 @@ withoutDevTools ? false , hydraProject , inputs +, tools , system ? builtins.currentSystem }: let @@ -16,7 +17,6 @@ let fourmolu = pkgs.haskell-nix.tool compiler "fourmolu" "0.14.0.0"; cabal-fmt = pkgs.haskell-nix.tool compiler "cabal-fmt" "0.1.9"; - hlint = pkgs.haskell-nix.tool compiler "hlint" "3.8"; apply-refact = pkgs.haskell-nix.tool compiler "apply-refact" "0.14.0.0"; # Build HLS form our fork (see flake.nix) @@ -47,7 +47,7 @@ let fourmolu cabal-fmt pkgs.nixpkgs-fmt - hlint + tools.hlint apply-refact # For validating JSON instances against a pre-defined schema pkgs.check-jsonschema @@ -159,7 +159,7 @@ let fourmolu cabal-fmt pkgs.nixpkgs-fmt - hlint + tools.hlint apply-refact ]; };