-
Notifications
You must be signed in to change notification settings - Fork 7
/
flake.nix
171 lines (158 loc) · 5.59 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
{
inputs.haskellNix.url = "github:input-output-hk/haskell.nix";
inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
inputs.easy-purescript-nix = {
url = "github:justinwoo/easy-purescript-nix";
flake = false;
};
outputs = { self, nixpkgs, flake-utils, haskellNix, easy-purescript-nix, pre-commit-hooks }:
let
supportedSystems = [
"x86_64-linux"
"x86_64-darwin"
];
in
flake-utils.lib.eachSystem supportedSystems (system:
let
easyPS =
let
p = pkgs.callPackage (easy-purescript-nix) { };
in
p // { purs = p.purs-0_15_2; };
fixPngOptimization = pkgs.callPackage ./nix/fix-png-optimization { };
fixStylishHaskell = pkgs.callPackage ./nix/fix-stylish-haskell { };
writeShellScriptBinInRepoRoot = name: script: pkgs.writeShellScriptBin name ''
cd `${pkgs.git}/bin/git rev-parse --show-toplevel`
${script}
'';
scripts = import ./nix/scripts.nix {
inherit pkgs easyPS writeShellScriptBinInRepoRoot;
inherit (pkgs.nodePackages) prettier;
};
formatting = import ./nix/formatting.nix {
inherit writeShellScriptBinInRepoRoot pkgs easyPS;
};
tests = import ./nix/tests/default.nix {
inherit pkgs fixPngOptimization fixStylishHaskell;
inherit (formatting) fix-prettier;
inherit (easyPS) purs-tidy;
src = ./.;
play-generated = scripts.generated-purescript;
};
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = (pkgs.lib.cleanSource ./.);
hooks = {
prettier = {
enable = true;
types_or = [ "javascript" "css" "html" ];
};
purs-tidy-hook = {
enable = true;
name = "purs-tidy";
description = "Ensure PureScript files are formatted";
entry = "${easyPS.purs-tidy}/bin/purs-tidy format-in-place";
files = "\\.purs$";
language = "system";
};
shellcheck.enable = true;
stylish-haskell.enable = true;
nixpkgs-fmt.enable = true;
png-optimization = {
enable = true;
name = "png-optimization";
description = "Ensure that PNG files are optimized";
entry = "${pkgs.optipng}/bin/optipng";
files = "\\.png$";
};
};
};
overlays = [
haskellNix.overlay
(final: prev: {
playground =
final.haskell-nix.cabalProject' {
src = ./.;
compiler-nix-name = "ghc8107";
shell.tools = {
cabal = { };
# hlint = {};
haskell-language-server = { };
};
shell.shellHook = ''
${pre-commit-check.shellHook}
# The green prompt familiar to those used to nix-shell
export PS1="\n\[\033[1;32m\][nix develop:\w]\$\[\033[0m\] "
'';
shell.buildInputs =
(with pkgs; [
nixpkgs-fmt
nodePackages.prettier
]
)
++
(with scripts; [
marlowe-playground-generate-purs
start-backend
]
)
++
(with formatting; [
fix-prettier
fix-purs-tidy
fix-nix-fmt
]
)
++
(with easyPS; [
purs-tidy
purs
spago
spago2nix
psa
purescript-language-server
pscid
]
++ [
fixPngOptimization
fixStylishHaskell
]
)
;
};
})
];
pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; };
flake = pkgs.playground.flake { };
ghc-with-marlowe = pkgs.playground.ghcWithPackages (ps: [ ps.marlowe ]);
in
pkgs.lib.recursiveUpdate
(flake // {
legacyPackages = pkgs;
})
{
packages = {
inherit ghc-with-marlowe fixPngOptimization fixStylishHaskell;
inherit (scripts) marlowe-playground-generate-purs generated-purescript;
inherit (formatting) fix-purs-tidy fix-nix-fmt;
test-nix-fmt = tests.nixpkgsFmt;
test-prettier = tests.prettier;
test-generated = tests.generated;
test-purs-tidy = tests.pursTidy;
test-png = tests.pngOptimization;
test-stylish-haskell = tests.stylishHaskell;
test-shell = tests.shellcheck;
};
}
);
# --- Flake Local Nix Configuration ----------------------------
nixConfig = {
# This sets the flake to use the IOG nix cache.
# Nix should ask for permission before using it,
# but remove it here if you do not want it to.
extra-substituters = [ "https://cache.iog.io" ];
extra-trusted-public-keys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ];
allow-import-from-derivation = "true";
};
}