From 13964faa53b09924bdd27328311ba27457b0b61d Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Wed, 16 Feb 2022 02:15:52 +0300 Subject: I hate the Antichrist --- flake.nix | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 10 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 426f9bd..9664dd0 100644 --- a/flake.nix +++ b/flake.nix @@ -24,25 +24,38 @@ ref = "master"; flake = false; }; + + pre-commit-hooks = { + type = "github"; + owner = "cachix"; + repo = "pre-commit-hooks.nix"; + ref = "master"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; + }; }; - outputs = { self, nixpkgs, flake-utils, ... }: - flake-utils.lib.eachDefaultSystem (system: + outputs = inputs: + with inputs; + let name = "xmonad-ng"; + in flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; project = returnShellEnv: pkgs.haskellPackages.developPackage { - inherit returnShellEnv; - name = "xmonad-ng"; + inherit name returnShellEnv; root = ./.; overrides = self: _: with pkgs.haskell.lib; - let version = "0.17.0"; + let + mkPackage = packageName: + dontCheck (self.callHackage packageName "0.17.0" { }); in { - xmonad = dontCheck (self.callHackage "xmonad" version { }); - xmonad-contrib = - dontCheck (self.callHackage "xmonad-contrib" version { }); + xmonad = mkPackage "xmonad"; + xmonad-contrib = mkPackage "xmonad-contrib"; }; modifier = drv: pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages; [ @@ -57,8 +70,39 @@ in { defaultPackage = project false; - devShell = project true; + checks.preCommit = pre-commit-hooks.lib.${system}.run { + src = ./.; + hooks = { + nix-linter.enable = true; + nixfmt.enable = true; + hpack.enable = true; + hlint.enable = true; + yamllint.enable = true; + brittany.enable = true; + shellcheck.enable = true; + shfmt = { + enable = true; + name = "shfmt"; + entry = "${pkgs.shfmt}/bin/shfmt -s -w"; + types = [ "shell" ]; + }; + prettier = { + enable = true; + types = [ ]; + files = "\\.((yaml)|\\d)$"; + }; + }; + }; + + shells = { + dev = project true; + commit = pkgs.mkShell { + inherit (self.checks.${system}.preCommit) shellHook; + }; + }; + + devShell = self.shells.${system}.dev; }) // { - overlay = _: _: { xmonad-ng = self.defaultPackage; }; + overlay = _: _: { ${name} = self.defaultPackage; }; }; } -- cgit 1.4.1