generated from srid/haskell-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
124 lines (107 loc) · 4.05 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
{
description = "codosseum/templatespliler: Nix template for Haskell projects";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
systems.url = "github:nix-systems/default";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
haskell-flake.url = "github:srid/haskell-flake";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
flake-root.url = "github:srid/flake-root";
pre-commit-hooks.url = "github:cachix/git-hooks.nix";
};
outputs = { self, pre-commit-hooks, ... } @ inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
imports = [
inputs.haskell-flake.flakeModule
inputs.treefmt-nix.flakeModule
inputs.flake-root.flakeModule
];
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.haskell.packages.ghc96;
projectRoot = ./.;
packages = {
base64.source = "1.0";
templatespiler-parser.source = ./templatespiler-parser;
templatespiler-converter.source = ./templatespiler-converter;
templatespiler-generator.source = ./templatespiler-generator;
templatespiler-server.source = ./templatespiler-server;
};
# Development shell configuration
devShell = {
hlsCheck.enable = false;
};
# What should haskell-flake add to flake outputs?
autoWire = [ "packages" "apps" "checks" ]; # Wire all but the devShell
};
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
treefmt.enable = true;
treefmt.package = config.treefmt.build.wrapper;
};
};
};
# 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;
programs.ormolu.enable = true;
programs.nixpkgs-fmt.enable = true;
programs.cabal-fmt.enable = true;
programs.hlint.enable = true;
# We use fourmolu
programs.ormolu.package = pkgs.haskellPackages.fourmolu;
settings.formatter.ormolu = {
options = [
"--ghc-opt"
"-XImportQualifiedPost"
];
};
};
# Default package & app.
packages.default = self'.packages.server;
apps.default = self'.apps.server;
# Default shell.
devShells.default = pkgs.mkShell {
name = "templatespliler";
inherit (self.checks.${system}.pre-commit-check) shellHook;
nativeBuildInputs = with pkgs; [
just
config.treefmt.build.wrapper
];
# See https://zero-to-flakes.com/haskell-flake/devshell#composing-devshells
inputsFrom = [
config.haskellProjects.default.outputs.devShell
config.flake-root.devShell
config.treefmt.build.devShell
];
};
packages.dockerImage = pkgs.dockerTools.buildImage {
name = "codosseum-org/templatespiler";
created = "now";
tag = builtins.substring 0 7 (self.rev or "dev");
config = {
Cmd = [ "${pkgs.lib.getExe self'.packages.default} server" ];
};
copyToRoot = pkgs.buildEnv {
paths = with pkgs; [
self'.packages.default
pkgs.bash
];
name = "server-root";
pathsToLink = [ "/bin" ];
};
};
};
};
}