-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
204 lines (190 loc) · 5.29 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
{
description = "Nix flake for Spoke. The universal data connector";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
zig-overlay = {
url = "github:mitchellh/zig-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
flake-utils,
nixpkgs,
zig-overlay,
...
}: let
systems = builtins.attrNames zig-overlay.packages;
outputs = flake-utils.lib.eachSystem systems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
zig-overlay.overlays.default
self.overlays
];
};
in rec {
# packages exported by the flake
packages = {
spoke-small = pkgs.spoke-small {release = "Small";};
spoke-fast = pkgs.spoke-fast {release = "Fast";};
spoke-debug = pkgs.spoke-debug {release = "Debug";};
docker-spoke-small = pkgs.dockerTools.buildImage {
name = "spoke-small";
config = {
Cmd = ["${packages.spoke-small}/bin/spoke"];
};
};
docker-spoke-fast = pkgs.dockerTools.buildImage {
name = "spoke-fast";
config = {
Cmd = ["${packages.spoke-fast}/bin/spoke"];
};
};
docker-spoke-debug = pkgs.dockerTools.buildImage {
name = "spoke-debug";
config = {
Cmd = ["${packages.spoke-debug}/bin/spoke"];
};
};
default = packages.spoke-small {};
};
# nix run
apps = {
test.hurl = {
type = "app";
program = toString (pkgs.writeScript "test.hurl" ''
export PATH="${pkgs.lib.makeBinPath (
with pkgs; [
hurl
]
)}"
hurl \
--variable protocol=http \
--variable host=localhost \
--variable port=3001 \
--test \
--glob "test/**/*.hurl"
'');
};
ui.dev = {
type = "app";
program = toString (pkgs.writeScript "ui.dev" ''
export PATH="${pkgs.lib.makeBinPath (
with pkgs; [
nodejs_20
]
)}:$PATH"
cd ui && npm run dev
'');
};
ui.format = {
type = "app";
program = toString (pkgs.writeScript "ui.format" ''
export PATH="${pkgs.lib.makeBinPath (
with pkgs; [
nodejs_20
]
)}:$PATH"
cd ui && npm run format
'');
};
ui.check = {
type = "app";
program = toString (pkgs.writeScript "ui.check" ''
export PATH="${pkgs.lib.makeBinPath (
with pkgs; [
nodejs_20
]
)}:$PATH"
cd ui && npm run check
'');
};
ui.lint = {
type = "app";
program = toString (pkgs.writeScript "ui.lint" ''
export PATH="${pkgs.lib.makeBinPath (
with pkgs; [
nodejs_20
]
)}:$PATH"
cd ui && npm run lint
'');
};
ui.test = {
type = "app";
program = toString (pkgs.writeScript "ui.test" ''
export PATH="${pkgs.lib.makeBinPath (
with pkgs; [
nodejs_20
]
)}:$PATH"
cd ui && npm run test:unit
'');
};
ui.build = {
type = "app";
program = toString (pkgs.writeScript "ui.build" ''
export PATH="${pkgs.lib.makeBinPath (
with pkgs; [
nodejs_20
]
)}:$PATH"
cd ui && npm run build
'');
};
ui.start = {
type = "app";
program = toString (pkgs.writeScript "ui.start" ''
export PATH="${pkgs.lib.makeBinPath (
with pkgs; [
nodejs_20
]
)}:$PATH"
cd ui && npm run start
'');
};
ui.open = {
type = "app";
program = toString (pkgs.writeScript "ui.open" ''
cd ui && open http://localhost:3000
'');
};
ui.install = {
type = "app";
program = toString (pkgs.writeScript "ui.install" ''
export PATH="${pkgs.lib.makeBinPath (
with pkgs; [
nodejs_20
]
)}:$PATH"
cd ui && npm install
'');
};
default = packages.spoke-fast;
};
# nix fmt
formatter = pkgs.alejandra;
# nix develop -c $SHELL
devShells.default = pkgs.mkShell {
packages = [
pkgs.bats
pkgs.hurl
pkgs.nodejs_20
pkgs.zigpkgs."0.11.0"
];
};
});
in
outputs
// {
# Overlay that can be imported so you can access the packages
# using spoke.overlays
overlays = final: prev: {
spoke-small = prev.pkgs.callPackage ./spoke.nix {release = "Small";};
spoke-fast = prev.pkgs.callPackage ./spoke.nix {release = "Fast";};
spoke-debug = prev.pkgs.callPackage ./spoke.nix {release = "Debug";};
};
};
}