-
Notifications
You must be signed in to change notification settings - Fork 6
/
flake.nix
111 lines (104 loc) · 3.55 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
{
description = "Ema template app";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
systems.url = "github:nix-systems/default";
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
fourmolu-nix.url = "github:jedimahdi/fourmolu-nix";
git-hooks.url = "github:cachix/git-hooks.nix";
git-hooks.flake = false;
ema.url = "github:srid/ema";
ema.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
imports = [
inputs.haskell-flake.flakeModule
inputs.process-compose-flake.flakeModule
inputs.fourmolu-nix.flakeModule
(inputs.git-hooks + /flake-module.nix)
];
perSystem = { config, pkgs, lib, ... }:
let
tailwind = pkgs.haskellPackages.tailwind;
in
{
# "haskellProjects" comes from https://github.com/srid/haskell-flake
haskellProjects.default = {
imports = [
inputs.ema.haskellFlakeProjectModules.output
];
autoWire = [ "packages" "apps" "checks" ];
};
pre-commit.settings = {
hooks = {
nixpkgs-fmt.enable = true;
cabal-fmt.enable = true;
fourmolu = {
enable = true;
package = config.fourmolu.wrapper;
};
hlint.enable = true;
};
};
fourmolu.settings = {
indentation = 2;
comma-style = "leading";
record-brace-space = true;
indent-wheres = true;
import-export-style = "diff-friendly";
respectful = true;
haddock-style = "multi-line";
newlines-between-decls = 1;
extensions = [ "ImportQualifiedPost" ];
};
process-compose."ema-tailwind-run" = {
cli.environment.PC_DISABLE_TUI = true;
settings = {
processes = {
haskell.command = "ghcid";
tailwind = {
command = "${lib.getExe tailwind} -w -o ./static/tailwind.css './src/**/*.hs'";
is_tty = true;
};
};
};
};
packages =
let
buildEmaSiteWithTailwind = { baseUrl }:
pkgs.runCommand "site"
{ }
''
mkdir -p $out
pushd ${inputs.self}
${lib.getExe config.packages.ema-template} \
--base-url=${baseUrl} gen $out
${lib.getExe tailwind} \
-o $out/tailwind.css 'src/**/*.hs'
'';
in
{
default = config.packages.ema-template;
site = buildEmaSiteWithTailwind { baseUrl = "/"; };
site-github = buildEmaSiteWithTailwind { baseUrl = "/ema-template/"; };
};
devShells.default = pkgs.mkShell {
name = "ema-template";
meta.description = "ema-template development environment";
packages = [
tailwind
pkgs.just
pkgs.nixd
];
inputsFrom = [
config.haskellProjects.default.outputs.devShell
config.pre-commit.devShell
];
};
};
};
}