matrix-media-expanded/flake.nix

97 lines
3.2 KiB
Nix
Raw Normal View History

2021-05-31 23:19:51 +00:00
{
description = "srid/haskell-template: Nix template for Haskell projects";
2021-05-31 23:19:51 +00:00
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
2022-05-26 11:25:38 +00:00
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
treefmt-nix.url = "github:Platonic-Systems/treefmt-nix/flake-module"; # https://github.com/numtide/treefmt-nix/pull/14
flake-root.url = "github:srid/flake-root";
mission-control.url = "github:Platonic-Systems/mission-control";
2021-05-31 23:19:51 +00:00
};
2022-04-27 22:55:51 +00:00
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [
inputs.haskell-flake.flakeModule
inputs.treefmt-nix.flakeModule
inputs.flake-root.flakeModule
inputs.mission-control.flakeModule
];
perSystem = { self', lib, config, pkgs, ... }: {
# The "main" project. You can have multiple projects, but this template
# has only one.
haskellProjects.main = {
packages = {
haskell-template.root = ./.;
};
buildTools = hp: {
2022-12-22 01:27:00 +00:00
treefmt = config.treefmt.build.wrapper;
} // config.treefmt.build.programs;
2022-09-14 20:46:58 +00:00
# overrides = self: super: {}
hlsCheck.enable = true;
hlintCheck.enable = true;
};
# Auto formatters. This also adds a flake check to ensure that the
# source tree was auto formatted.
treefmt.config = {
2022-12-22 01:31:32 +00:00
inherit (config.flake-root) projectRootFile;
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;
# We use fourmolu
programs.ormolu.package = pkgs.haskellPackages.fourmolu;
settings.formatter.ormolu = {
options = [
"--ghc-opt"
"-XImportQualifiedPost"
];
};
2022-05-26 11:25:38 +00:00
};
# Dev shell scripts.
mission-control.scripts = {
docs = {
description = "Start Hoogle server for project dependencies";
2022-12-19 16:17:13 +00:00
exec = ''
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 = ''
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}";
2022-12-19 13:58:06 +00:00
category = "Dev Tools ";
};
run = {
description = "Run the project with ghcid auto-recompile";
2022-12-19 16:17:13 +00:00
exec = ''
ghcid -c "cabal repl exe:haskell-template" --warnings -T :main
'';
category = "Primary";
};
};
# Default package.
packages.default = self'.packages.main-haskell-template;
# Default shell.
devShells.default =
config.mission-control.installToDevShell self'.devShells.main;
};
2022-12-23 17:45:02 +00:00
flake.herculesCI.ciSystems = [ "x86_64-linux" "aarch64-darwin" ];
2022-05-26 11:25:38 +00:00
};
2021-05-31 23:19:51 +00:00
}