2021-05-31 23:19:51 +00:00
|
|
|
{
|
2022-05-30 13:16:38 +00:00
|
|
|
description = "srid/haskell-template: Nix template for Haskell projects";
|
2021-05-31 23:19:51 +00:00
|
|
|
inputs = {
|
2022-05-07 00:27:11 +00:00
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
2022-05-26 11:25:38 +00:00
|
|
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
2022-05-30 13:16:38 +00:00
|
|
|
haskell-flake.url = "github:srid/haskell-flake";
|
2022-12-24 11:53:10 +00:00
|
|
|
treefmt-nix.url = "github:numtide/treefmt-nix";
|
2023-03-02 14:21:25 +00:00
|
|
|
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
|
2022-12-19 14:27:56 +00:00
|
|
|
flake-root.url = "github:srid/flake-root";
|
2022-12-17 17:29:11 +00:00
|
|
|
mission-control.url = "github:Platonic-Systems/mission-control";
|
2023-02-11 20:04:27 +00:00
|
|
|
|
|
|
|
nixpkgs-140774-workaround.url = "github:srid/nixpkgs-140774-workaround";
|
2021-05-31 23:19:51 +00:00
|
|
|
};
|
2022-04-27 22:55:51 +00:00
|
|
|
|
2022-08-28 22:50:08 +00:00
|
|
|
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
|
2022-12-19 16:16:12 +00:00
|
|
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
2022-05-27 20:31:08 +00:00
|
|
|
systems = nixpkgs.lib.systems.flakeExposed;
|
2022-05-30 13:16:38 +00:00
|
|
|
imports = [
|
2022-08-28 22:50:08 +00:00
|
|
|
inputs.haskell-flake.flakeModule
|
2022-12-21 18:09:33 +00:00
|
|
|
inputs.treefmt-nix.flakeModule
|
2022-12-19 14:27:56 +00:00
|
|
|
inputs.flake-root.flakeModule
|
2022-12-17 17:29:11 +00:00
|
|
|
inputs.mission-control.flakeModule
|
2022-05-30 13:16:38 +00:00
|
|
|
];
|
2023-02-05 19:31:22 +00:00
|
|
|
perSystem = { self', system, lib, config, pkgs, ... }: {
|
2022-12-19 14:27:56 +00:00
|
|
|
# The "main" project. You can have multiple projects, but this template
|
|
|
|
# has only one.
|
2022-12-17 17:29:11 +00:00
|
|
|
haskellProjects.main = {
|
2023-02-11 20:04:27 +00:00
|
|
|
imports = [
|
|
|
|
inputs.nixpkgs-140774-workaround.haskellFlakeProjectModules.default
|
|
|
|
];
|
|
|
|
# packages.haskell-template.root = ./.; # Auto-discovered by haskell-flake
|
|
|
|
overrides = self: super: { };
|
2023-02-05 19:31:22 +00:00
|
|
|
devShell = {
|
|
|
|
tools = hp: {
|
2023-01-24 18:02:42 +00:00
|
|
|
treefmt = config.treefmt.build.wrapper;
|
|
|
|
} // config.treefmt.build.programs;
|
2023-02-05 19:37:24 +00:00
|
|
|
hlsCheck.enable = true;
|
2023-02-05 19:31:22 +00:00
|
|
|
};
|
2022-08-17 18:23:47 +00:00
|
|
|
};
|
2022-12-19 14:27:56 +00:00
|
|
|
|
|
|
|
# Auto formatters. This also adds a flake check to ensure that the
|
|
|
|
# source tree was auto formatted.
|
2022-12-21 18:09:33 +00:00
|
|
|
treefmt.config = {
|
2022-12-22 01:31:32 +00:00
|
|
|
inherit (config.flake-root) projectRootFile;
|
2022-12-21 18:09:33 +00:00
|
|
|
package = pkgs.treefmt;
|
|
|
|
|
|
|
|
programs.ormolu.enable = true;
|
2022-12-22 01:31:32 +00:00
|
|
|
programs.nixpkgs-fmt.enable = true;
|
|
|
|
programs.cabal-fmt.enable = true;
|
2023-02-06 22:57:23 +00:00
|
|
|
programs.hlint.enable = true;
|
2022-12-22 01:31:32 +00:00
|
|
|
|
|
|
|
# We use fourmolu
|
2022-12-21 18:09:33 +00:00
|
|
|
programs.ormolu.package = pkgs.haskellPackages.fourmolu;
|
|
|
|
settings.formatter.ormolu = {
|
|
|
|
options = [
|
|
|
|
"--ghc-opt"
|
|
|
|
"-XImportQualifiedPost"
|
|
|
|
];
|
|
|
|
};
|
2022-05-26 11:25:38 +00:00
|
|
|
};
|
2022-12-19 14:27:56 +00:00
|
|
|
|
|
|
|
# Dev shell scripts.
|
2022-12-17 17:29:11 +00:00
|
|
|
mission-control.scripts = {
|
|
|
|
docs = {
|
|
|
|
description = "Start Hoogle server for project dependencies";
|
2022-12-19 16:17:13 +00:00
|
|
|
exec = ''
|
2022-12-17 17:29:11 +00:00
|
|
|
echo http://127.0.0.1:8888
|
|
|
|
hoogle serve -p 8888 --local
|
|
|
|
'';
|
|
|
|
category = "Dev Tools";
|
|
|
|
};
|
|
|
|
repl = {
|
|
|
|
description = "Start the cabal repl";
|
2022-12-19 16:17:13 +00:00
|
|
|
exec = ''
|
2022-12-17 17:29:11 +00:00
|
|
|
cabal repl "$@"
|
|
|
|
'';
|
|
|
|
category = "Dev Tools";
|
|
|
|
};
|
|
|
|
fmt = {
|
2022-12-19 13:58:06 +00:00
|
|
|
description = "Format the source tree";
|
2022-12-22 01:27:00 +00:00
|
|
|
exec = "${lib.getExe config.treefmt.build.wrapper}";
|
2023-03-08 17:16:08 +00:00
|
|
|
category = "Dev Tools";
|
2022-12-17 17:29:11 +00:00
|
|
|
};
|
|
|
|
run = {
|
|
|
|
description = "Run the project with ghcid auto-recompile";
|
2022-12-19 16:17:13 +00:00
|
|
|
exec = ''
|
2022-12-17 17:29:11 +00:00
|
|
|
ghcid -c "cabal repl exe:haskell-template" --warnings -T :main
|
|
|
|
'';
|
|
|
|
category = "Primary";
|
|
|
|
};
|
|
|
|
};
|
2022-12-19 14:27:56 +00:00
|
|
|
|
|
|
|
# Default package.
|
2022-12-17 17:29:11 +00:00
|
|
|
packages.default = self'.packages.main-haskell-template;
|
2022-12-19 14:27:56 +00:00
|
|
|
|
|
|
|
# Default shell.
|
2022-12-17 17:29:11 +00:00
|
|
|
devShells.default =
|
2022-12-19 14:27:56 +00:00
|
|
|
config.mission-control.installToDevShell self'.devShells.main;
|
2022-05-30 13:16:38 +00:00
|
|
|
};
|
2022-05-26 11:25:38 +00:00
|
|
|
};
|
2021-05-31 23:19:51 +00:00
|
|
|
}
|