matrix-media-expanded/flake.nix

148 lines
4.7 KiB
Nix
Raw Permalink Normal View History

2021-05-31 23:19:51 +00:00
{
2023-06-10 08:57:15 +00:00
description = "matrix-media-expanded";
2021-05-31 23:19:51 +00:00
inputs = {
2023-06-10 08:57:15 +00:00
nixpkgs.url = "github:nixos/nixpkgs";
systems.url = "github:nix-systems/default";
2022-05-26 11:25:38 +00:00
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
2022-12-24 11:53:10 +00:00
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
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
2023-04-28 20:26:17 +00:00
outputs = inputs:
2023-06-10 14:28:09 +00:00
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
imports = [
inputs.haskell-flake.flakeModule
inputs.treefmt-nix.flakeModule
inputs.flake-root.flakeModule
inputs.mission-control.flakeModule
];
2023-06-10 14:28:09 +00:00
perSystem =
{ self'
, system
, lib
, config
, pkgs
, ...
}: {
# Our only Haskell project. You can have multiple projects, but this template
# has only one.
# See https://github.com/srid/haskell-flake/blob/master/example/flake.nix
haskellProjects.default = {
# The base package set (this value is the default)
# basePackages = pkgs.haskellPackages;
2023-06-10 14:28:09 +00:00
# Packages to add on top of `basePackages`
packages = {
# Add source or Hackage overrides here
# (Local packages are added automatically)
/*
2023-06-10 08:57:15 +00:00
aeson.source = "1.5.0.0" # Hackage version
shower.source = inputs.shower; # Flake input
2023-06-10 14:28:09 +00:00
*/
};
2023-06-10 14:28:09 +00:00
# Add your package overrides here
settings = {
/*
2023-06-10 08:57:15 +00:00
haskell-template = {
haddock = false;
};
aeson = {
check = false;
};
2023-06-10 14:28:09 +00:00
*/
};
2023-06-10 14:28:09 +00:00
# Development shell configuration
devShell = {
# TODO: Remove this after https://github.com/numtide/treefmt-nix/issues/65
tools = hp:
{
treefmt = config.treefmt.build.wrapper;
}
// config.treefmt.build.programs;
hlsCheck.enable = false;
};
2023-06-10 14:28:09 +00:00
# What should haskell-flake add to flake outputs?
autoWire = [ "packages" "apps" "checks" ]; # Wire all but the devShell
};
2023-06-10 14:28:09 +00:00
# Auto formatters. This also adds a flake check to ensure that the
# source tree was auto formatted.
treefmt.config = {
inherit (config.flake-root) projectRootFile;
package = pkgs.treefmt;
2023-06-10 14:28:09 +00:00
programs.ormolu.enable = true;
programs.nixpkgs-fmt.enable = true;
programs.cabal-fmt.enable = true;
programs.hlint.enable = true;
2022-12-22 01:31:32 +00:00
2023-06-10 14:28:09 +00:00
# We use fourmolu
programs.ormolu.package = pkgs.haskellPackages.fourmolu;
settings.formatter.ormolu = {
options = [
"--ghc-opt"
"-XImportQualifiedPost"
];
};
};
2023-06-10 14:28:09 +00:00
# Dev shell scripts.
mission-control.scripts = {
docs = {
description = "Start Hoogle server for project dependencies";
exec = ''
echo http://127.0.0.1:8888
hoogle serve -p 8888 --local
'';
category = "Dev Tools";
};
repl = {
description = "Start the cabal repl";
exec = ''
cabal repl "$@"
'';
category = "Dev Tools";
};
fmt = {
description = "Format the source tree";
exec = config.treefmt.build.wrapper;
category = "Dev Tools";
};
run = {
description = "Run the project with ghcid auto-recompile";
exec = ''
ghcid -c "cabal repl exe:matrix-media-expanded" --warnings -T :main
'';
category = "Primary";
};
};
2023-06-10 14:28:09 +00:00
# Default package & app.
packages.default = self'.packages.matrix-media-expanded;
apps.default = self'.apps.matrix-media-expanded;
2023-06-10 14:28:09 +00:00
# Default shell.
devShells.default = pkgs.mkShell {
name = "matrix-media-expanded";
inputsFrom = [
config.haskellProjects.default.outputs.devShell
config.flake-root.devShell
config.mission-control.devShell
];
};
};
2023-06-10 08:57:15 +00:00
flake = {
hydraJobs = {
2023-06-10 14:12:37 +00:00
inherit (inputs.self) packages devShells checks;
2023-06-10 08:57:15 +00:00
};
};
2022-05-26 11:25:38 +00:00
};
2021-05-31 23:19:51 +00:00
}