|
1 |
| -# SPDX-FileCopyrightText: 2020 Serokell <https://serokell.io/> |
| 1 | +# © 2019 Serokell <[email protected]> |
| 2 | +# © 2019 Lars Jellema <[email protected]> |
| 3 | +# © 2024 Silvan Mosberger <[email protected]> |
2 | 4 | #
|
3 | 5 | # SPDX-License-Identifier: MPL-2.0
|
4 | 6 |
|
5 |
| -(import |
6 |
| - ( |
7 |
| - let |
8 |
| - lock = builtins.fromJSON (builtins.readFile ./flake.lock); |
9 |
| - in |
10 |
| - fetchTarball { |
11 |
| - url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; |
12 |
| - sha256 = lock.nodes.flake-compat.locked.narHash; |
13 |
| - } |
14 |
| - ) |
15 |
| - { |
16 |
| - src = ./.; |
17 |
| - }).defaultNix |
| 7 | +{ |
| 8 | + system ? builtins.currentSystem, |
| 9 | + sources ? import ./npins, |
| 10 | +}: |
| 11 | +let |
| 12 | + overlay = self: super: { |
| 13 | + haskell = super.haskell // { |
| 14 | + packageOverrides = self: super: { |
| 15 | + nixfmt = self.callCabal2nix "nixfmt" src { }; |
| 16 | + }; |
| 17 | + }; |
| 18 | + }; |
| 19 | + |
| 20 | + pkgs = import sources.nixpkgs { |
| 21 | + inherit system; |
| 22 | + overlays = [ overlay (import (sources.serokell-nix + "/overlay")) ]; |
| 23 | + config = {}; |
| 24 | + }; |
| 25 | + |
| 26 | + inherit (pkgs) haskell lib; |
| 27 | + |
| 28 | + regexes = |
| 29 | + [ ".*.cabal$" "^src.*" "^main.*" "^Setup.hs$" "^js.*" "LICENSE" ]; |
| 30 | + src = builtins.path { |
| 31 | + path = ./.; |
| 32 | + name = "nixfmt-src"; |
| 33 | + filter = path: type: |
| 34 | + let relPath = lib.removePrefix (toString ./. + "/") (toString path); |
| 35 | + in lib.any (re: builtins.match re relPath != null) regexes; |
| 36 | + }; |
| 37 | + |
| 38 | + build = pkgs.haskellPackages.nixfmt; |
| 39 | + |
| 40 | +in |
| 41 | +build // rec { |
| 42 | + packages = { |
| 43 | + nixfmt = build; |
| 44 | + nixfmt-static = haskell.lib.justStaticExecutables packages.nixfmt; |
| 45 | + nixfmt-deriver = packages.nixfmt-static.cabal2nixDeriver; |
| 46 | + |
| 47 | + nixfmt-shell = packages.nixfmt.env.overrideAttrs (oldAttrs: { |
| 48 | + buildInputs = oldAttrs.buildInputs ++ (with pkgs; [ |
| 49 | + # nixfmt: expand |
| 50 | + cabal-install |
| 51 | + stylish-haskell |
| 52 | + shellcheck |
| 53 | + npins |
| 54 | + ]); |
| 55 | + }); |
| 56 | + |
| 57 | + inherit (pkgs) reuse; |
| 58 | + }; |
| 59 | + |
| 60 | + shell = packages.nixfmt-shell; |
| 61 | + |
| 62 | + checks = { |
| 63 | + hlint = pkgs.build.haskell.hlint ./.; |
| 64 | + stylish-haskell = pkgs.build.haskell.stylish-haskell ./.; |
| 65 | + }; |
| 66 | +} |
0 commit comments