|
30 | 30 | url = "github:edolstra/flake-compat";
|
31 | 31 | flake = false;
|
32 | 32 | };
|
33 |
| - |
| 33 | + flake-parts.url = "github:hercules-ci/flake-parts"; |
| 34 | + pre-commit-hooks-nix.url = "github:cachix/pre-commit-hooks.nix"; |
34 | 35 | };
|
35 | 36 |
|
36 | 37 | outputs =
|
37 |
| - { self, nixpkgs, haskell-nix, CHaP, iohk-nix, cardano-node, ... }: |
| 38 | + inputs@{ self, nixpkgs, haskell-nix, CHaP, iohk-nix, cardano-node, flake-parts, ... }: |
38 | 39 | let
|
39 | 40 | defaultSystems = [ "x86_64-linux" "x86_64-darwin" ];
|
40 | 41 |
|
|
130 | 131 |
|
131 | 132 | modules = haskellModules system;
|
132 | 133 | };
|
| 134 | + |
| 135 | + project = perSystem projectFor; |
| 136 | + flake = perSystem (system: (projectFor system).flake { }); |
133 | 137 | in
|
134 |
| - { |
135 |
| - project = perSystem projectFor; |
136 |
| - flake = perSystem (system: (projectFor system).flake { }); |
137 |
| - |
138 |
| - defaultPackage = perSystem (system: |
139 |
| - let lib = "plutip-core:lib:plutip-core"; |
140 |
| - in self.flake.${system}.packages.${lib}); |
141 |
| - |
142 |
| - packages = perSystem (system: self.flake.${system}.packages); |
143 |
| - |
144 |
| - apps = perSystem (system: self.flake.${system}.apps); |
145 |
| - |
146 |
| - devShell = perSystem (system: self.flake.${system}.devShell); |
147 |
| - |
148 |
| - # This will build all of the project's executables and the tests |
149 |
| - check = perSystem |
150 |
| - (system: |
151 |
| - (nixpkgsFor system).runCommand "combined-check" |
152 |
| - { |
153 |
| - nativeBuildInputs = builtins.attrValues self.checks.${system} |
154 |
| - ++ builtins.attrValues self.flake.${system}.packages; |
155 |
| - } ''mkdir $out'' |
156 |
| - ); |
157 |
| - |
158 |
| - checks = perSystem (system: |
159 |
| - self.flake.${system}.checks // { |
160 |
| - formatting = (nixpkgsFor system).runCommand "formatting-check" |
161 |
| - { |
162 |
| - nativeBuildInputs = [ |
163 |
| - self.devShell.${system}.inputDerivation |
164 |
| - self.devShell.${system}.nativeBuildInputs |
165 |
| - ]; |
166 |
| - } |
167 |
| - '' |
168 |
| - cd ${self} |
169 |
| - export LC_CTYPE=C.UTF-8 |
170 |
| - export LC_ALL=C.UTF-8 |
171 |
| - export LANG=C.UTF-8 |
172 |
| - export IN_NIX_SHELL='pure' |
173 |
| - # this check is temporarily skipped in CI due to a bug in |
174 |
| - # fourmolu: |
175 |
| - # |
176 |
| - # ``` |
177 |
| - # Formatting is not idempotent: |
178 |
| - # src/Plutip/Launch/Cluster.hs<rendered>:753:19 |
179 |
| - # before: " sgs\n " |
180 |
| - # after: " sgs{ Ledger.s" |
181 |
| - # Please, consider reporting the bug. |
182 |
| - # ``` |
183 |
| - # make format_check cabalfmt_check nixpkgsfmt_check lint |
184 |
| - mkdir $out |
185 |
| - ''; |
186 |
| - }); |
187 |
| - |
188 |
| - haskellModules = perSystem haskellModules; |
189 |
| - |
190 |
| - # Instruction for the Hercules CI to build on x86_64-linux only, to avoid errors about systems without agents. |
191 |
| - herculesCI.ciSystems = [ "x86_64-linux" ]; |
| 138 | + flake-parts.lib.mkFlake { inherit inputs; } { |
| 139 | + imports = [ |
| 140 | + ./pre-commit.nix |
| 141 | + ]; |
| 142 | + flake = { |
| 143 | + inherit project flake; |
| 144 | + |
| 145 | + # This will build all of the project's executables and the tests |
| 146 | + check = perSystem |
| 147 | + (system: |
| 148 | + (nixpkgsFor system).runCommand "combined-check" |
| 149 | + { |
| 150 | + nativeBuildInputs = builtins.attrValues self.checks.${system} |
| 151 | + ++ builtins.attrValues self.flake.${system}.packages; |
| 152 | + } ''mkdir $out'' |
| 153 | + ); |
| 154 | + |
| 155 | + haskellModules = perSystem haskellModules; |
| 156 | + |
| 157 | + # Instruction for the Hercules CI to build on x86_64-linux only, to avoid errors about systems without agents. |
| 158 | + herculesCI.ciSystems = [ "x86_64-linux" ]; |
| 159 | + }; |
| 160 | + systems = defaultSystems; |
| 161 | + perSystem = { system, config, pkgs, ... }: { |
| 162 | + packages = flake.${system}.packages |
| 163 | + // { |
| 164 | + default = config.packages."plutip-core:lib:plutip-core"; |
| 165 | + }; |
| 166 | + |
| 167 | + apps = flake.${system}.apps; |
| 168 | + |
| 169 | + devShells = { |
| 170 | + # Adds pre-commit packages and shell hook to the haskell shell |
| 171 | + default = pkgs.mkShell { |
| 172 | + inputsFrom = [ config.devShells.haskell config.devShells.dev-pre-commit ]; |
| 173 | + shellHook = config.devShells.haskell.shellHook + config.devShells.dev-pre-commit.shellHook; |
| 174 | + }; |
| 175 | + haskell = flake.${system}.devShell; |
| 176 | + }; |
| 177 | + |
| 178 | + checks = flake.${system}.checks; |
| 179 | + }; |
192 | 180 | };
|
193 | 181 | }
|
0 commit comments