forked from hasura/graphql-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
236 lines (200 loc) · 8.14 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
{
description = "DDN Engine";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
};
outputs = { self, nixpkgs, flake-utils, crane, rust-overlay }:
flake-utils.lib.eachDefaultSystem
(localSystem:
let
version = pkgs.lib.strings.fileContents ./nix/version;
pkgs = import nixpkgs {
system = localSystem;
overlays = [ rust-overlay.overlays.default ];
};
rust = import ./nix/rust.nix {
inherit nixpkgs rust-overlay crane localSystem;
};
rust-x86_64-linux = (import ./nix/rust.nix {
inherit nixpkgs rust-overlay crane localSystem;
crossSystem = "x86_64-linux";
});
rust-aarch64-linux = (import ./nix/rust.nix {
inherit nixpkgs rust-overlay crane localSystem;
crossSystem = "aarch64-linux";
});
in
{
formatter = pkgs.nixpkgs-fmt;
packages = {
###### ENGINE
# engine binary for whichever is the local machine
engine = rust.callPackage ./nix/app.nix {
inherit version;
pname = "engine";
};
# engine binary for x86_64-linux
engine-x86_64-linux = rust-x86_64-linux.callPackage ./nix/app.nix {
inherit version;
pname = "engine";
};
# engine binary for aarch64-linux
engine-aarch64-linux = rust-aarch64-linux.callPackage ./nix/app.nix {
inherit version;
pname = "engine";
};
# engine docker files for whichever is the local machine
engine-docker = pkgs.callPackage ./nix/docker.nix {
package = self.packages.${localSystem}.engine;
image-name = "ghcr.io/hasura/v3-engine";
tag = "dev";
port = "3000";
};
# engine docker for x86_64-linux
engine-docker-x86_64-linux = pkgs.callPackage ./nix/docker.nix {
package = self.packages.${localSystem}.engine-x86_64-linux;
architecture = "amd64";
image-name = "ghcr.io/hasura/v3-engine";
port = "3000";
};
# engine docker for aarch64-linux
engine-docker-aarch64-linux = pkgs.callPackage ./nix/docker.nix {
package = self.packages.${localSystem}.engine-aarch64-linux;
architecture = "arm64";
image-name = "ghcr.io/hasura/v3-engine";
port = "3000";
};
default = self.packages.${localSystem}.engine;
###### CUSTOM_CONNECTOR
# custom-connector binary for whichever is the local machine
custom-connector = rust.callPackage ./nix/app.nix {
inherit version;
pname = "custom-connector";
};
# custom-connector binary for x86_64-linux
custom-connector-x86_64-linux = rust-x86_64-linux.callPackage ./nix/app.nix {
inherit version;
pname = "custom-connector";
};
# custom-connector binary for aarch64-linux
custom-connector-aarch64-linux = rust-aarch64-linux.callPackage ./nix/app.nix {
inherit version;
pname = "custom-connector";
};
# custom-connector docker files for whichever is the local machine
custom-connector-docker = pkgs.callPackage ./nix/docker.nix {
package = self.packages.${localSystem}.custom-connector;
image-name = "ghcr.io/hasura/v3-custom-connector";
tag = "dev";
port = "8181";
};
# custom-connector docker for x86_64-linux
custom-connector-docker-x86_64-linux = pkgs.callPackage ./nix/docker.nix {
package = self.packages.${localSystem}.custom-connector-x86_64-linux;
architecture = "amd64";
image-name = "ghcr.io/hasura/v3-custom-connector";
port = "8181";
};
# custom-connector docker for aarch64-linux
custom-connector-docker-aarch64-linux = pkgs.callPackage ./nix/docker.nix {
package = self.packages.${localSystem}.custom-connector-aarch64-linux;
architecture = "arm64";
image-name = "ghcr.io/hasura/v3-custom-connector";
port = "8181";
};
###### DEV-AUTH-WEBHOOK
# dev-auth-webhook binary for whichever is the local machine
dev-auth-webhook = rust.callPackage ./nix/app.nix {
inherit version;
pname = "dev-auth-webhook";
};
# dev-auth-webhook binary for x86_64-linux
dev-auth-webhook-x86_64-linux = rust-x86_64-linux.callPackage ./nix/app.nix {
inherit version;
pname = "dev-auth-webhook";
};
# dev-auth-webhook binary for aarch64-linux
dev-auth-webhook-aarch64-linux = rust-aarch64-linux.callPackage ./nix/app.nix {
inherit version;
pname = "dev-auth-webhook";
};
# dev-auth-webhook docker files for whichever is the local machine
dev-auth-webhook-docker = pkgs.callPackage ./nix/docker.nix {
package = self.packages.${localSystem}.dev-auth-webhook;
image-name = "ghcr.io/hasura/v3-dev-auth-webhook";
tag = "dev";
port = "3050";
};
# dev-auth-webhook docker for x86_64-linux
dev-auth-webhook-docker-x86_64-linux = pkgs.callPackage ./nix/docker.nix {
package = self.packages.${localSystem}.dev-auth-webhook-x86_64-linux;
architecture = "amd64";
image-name = "ghcr.io/hasura/v3-dev-auth-webhook";
port = "3050";
};
# dev-auth-webhook docker for aarch64-linux
dev-auth-webhook-docker-aarch64-linux = pkgs.callPackage ./nix/docker.nix {
package = self.packages.${localSystem}.dev-auth-webhook-aarch64-linux;
architecture = "arm64";
image-name = "ghcr.io/hasura/v3-dev-auth-webhook";
port = "3050";
};
### SCRIPTS
publish-docker-image = pkgs.writeShellApplication {
name = "publish-docker-image";
runtimeInputs = with pkgs; [ coreutils skopeo ];
text = builtins.readFile ./.github/scripts/deploy.sh;
};
};
apps = {
default = self.apps.${localSystem}.engine;
engine = flake-utils.lib.mkApp {
drv = self.packages.${localSystem}.engine;
name = "engine";
};
dev-auth-webhook = flake-utils.lib.mkApp {
drv = self.packages.${localSystem}.dev-auth-webhook;
name = "dev-auth-webhook";
};
custom-connector = flake-utils.lib.mkApp {
drv = self.packages.${localSystem}.custom-connector;
name = "custom-connector";
};
};
devShells = {
default = pkgs.mkShell {
# include dependencies of the default package
inputsFrom = [ self.packages.${localSystem}.default ];
# build-time inputs
nativeBuildInputs = [
# Development
pkgs.just
pkgs.moreutils
pkgs.nixpkgs-fmt
pkgs.nodePackages.prettier
# Rust
pkgs.bacon
pkgs.cargo-edit
pkgs.cargo-expand
pkgs.cargo-flamegraph
pkgs.cargo-insta
pkgs.cargo-machete
pkgs.cargo-nextest
pkgs.cargo-watch
rust.rustToolchain
];
};
};
});
}