-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
248 lines (227 loc) · 7.52 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/haskell-updates";
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
check-flake.url = "github:srid/check-flake";
flake-root.url = "github:srid/flake-root";
purescript-overlay.url = "github:thomashoneyman/purescript-overlay";
purescript-overlay.inputs.nixpkgs.follows = "nixpkgs";
# flake-utils.url = "github:numtide/flake-utils";
purs-nix.url = "github:purs-nix/purs-nix";
ps-tools.follows = "purs-nix/ps-tools";
purescript-bridge.url =
"github:eskimor/purescript-bridge/d43987ea406dbeb4f4013ecb857686a1b19451f0";
purescript-bridge.flake = false;
feedback.url = "github:NorfairKing/feedback";
# /4cee717e3e0003b76e699550f5fc35976901078c
# argonaut-aeson-generic-in.src.flake.url = "github:coot/purescript-argonaut-aeson-generic";
};
outputs = inputs@{ self
, nixpkgs
, flake-parts
, haskell-flake
, check-flake
, flake-root
, purescript-overlay
, purs-nix
, ps-tools
, purescript-bridge
, feedback
}:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
imports = [
haskell-flake.flakeModule
flake-root.flakeModule
check-flake.flakeModule
];
perSystem = { self', pkgs, system, config,... }:
let
purs-nix = inputs.purs-nix { inherit system; };
ps-tools = inputs.ps-tools.legacyPackages.${system};
argonaut-aeson-generic = purs-nix.build {
name = "argonaut-aeson-generic";
info =
{ dependencies =
with purs-nix.ps-pkgs;
[ argonaut
argonaut-codecs
argonaut-generic
console
effect
foreign-object
test-unit
];
};
# src.flake.url = "github:coot/purescript-argonaut-aeson-generic/4cee717e3e0003b76e699550f5fc35976901078c";
src.git = {
repo = "https://github.com/coot/purescript-argonaut-aeson-generic.git";
rev = "4cee717e3e0003b76e699550f5fc35976901078c";
};
};
foreign-generic = purs-nix.build {
name = "foreign-generic";
info =
{ dependencies =
with purs-nix.ps-pkgs;
[ effect
foreign
foreign-object
ordered-collections
exceptions
record
identity
];
};
src.git = {
repo = "https://github.com/peterbecich/purescript-foreign-generic.git";
rev = "844f2ababa2c7a0482bf871e1e6bf970b7e51313";
sha256 = "1df3n2yq8gmndldl0i1b3xqal50q12za61vgafdd13h1zf9cp3j3";
};
};
ps = purs-nix.purs {
dependencies = with purs-nix.ps-pkgs; [
aff
affjax
affjax-web
argonaut-aeson-generic
argonaut-codecs
argonaut-core
arrays
colors
console
css
effect
either
foldable-traversable
foreign
foreign-generic
halogen
halogen-css
halogen-store
maybe
newtype
prelude
profunctor-lenses
routing
routing-duplex
tuples
unordered-collections
];
srcs = [ "app" "src" ];
dir = ./.;
};
staticFiles = pkgs.stdenv.mkDerivation {
name = "bundle-static-files";
src = ./static;
installPhase = ''
mkdir -p $out/app/static/
ls
cp -r * $out/app/static/
'';
};
in {
# https://flake.parts/overlays#consuming-an-overlay
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
purescript-overlay.overlays.default
];
};
haskellProjects.default = {
# basePackages = pkgs.haskell.packages.ghc98;
basePackages = pkgs.haskellPackages;
settings = {
brick.jailbreak = true;
# https://community.flake.parts/haskell-flake/dependency#nixpkgs
# vty = { super, ... }:
# { custom = _: super.vty_5_35_1; };
};
packages = {
chessIO.source = "0.6.1.1";
brick.source = "0.73";
vty.source = "5.39";
purescript-bridge.source = inputs.purescript-bridge;
};
devShell = {
enable = true;
tools = haskellPackages: {
inherit (haskellPackages) zlib stylish-haskell;
};
hlsCheck.enable = false;
};
# exclude devShell, fixes duplicate definition
autoWire = [ "packages" "apps" "checks" ];
};
devShells.default = pkgs.mkShell {
inputsFrom = [
config.haskellProjects.default.outputs.devShell
];
buildInputs = with pkgs; [
# haskellPackages.feedback
feedback.packages.${system}.default
purs
spago
purs-tidy-bin.purs-tidy-0_10_0
purs-backend-es
purescript-language-server
purs-nix.esbuild
purs-nix.purescript
(ps.command {})
];
};
# https://github.com/purs-nix/purs-nix/blob/master/docs/derivations.md#app
packages.foo = ps.app {
name = "main.js";
esbuild = {
format = "iife";
};
};
packages.bar = pkgs.stdenv.mkDerivation rec {
name = "javascript bundle";
src = self'.packages.foo;
dontUnpack = true;
installPhase = ''
mkdir -p $out/app/static
cp $src/bin/main.js $out/app/static/main.js
'';
};
packages.dockerImage = pkgs.dockerTools.buildImage {
name = "peterbecich/halogen-chess";
tag = "latest";
created = "now";
copyToRoot = pkgs.buildEnv {
name = "image-root";
pathsToLink = [ "/bin" "/app/static" ];
paths = [
self'.packages.halogen-chess
staticFiles
self'.packages.bar
];
# paths
};
config = {
Cmd = [ "halogen-chess" ];
Env = [
"CLIENT_DIR=/app/static"
];
ExposedPorts = {
"8080/tcp" = {};
};
};
};
# packages.localDevelopment =
# pkgs.writeShellScriptBin "my-script" ''
# echo "start server"
# feedback test
# '';
packages.default = self'.packages.halogen-chess;
};
};
}