-
Notifications
You must be signed in to change notification settings - Fork 42
/
flake.nix
184 lines (154 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
{
description = "Nhost Hasura Storage";
inputs = {
nixops.url = "github:nhost/nixops";
nixpkgs.follows = "nixops/nixpkgs";
flake-utils.follows = "nixops/flake-utils";
nix-filter.follows = "nixops/nix-filter";
};
outputs = { self, nixops, nixpkgs, flake-utils, nix-filter }:
flake-utils.lib.eachDefaultSystem (system:
let
localOverlay = import ./nix/overlay.nix;
overlays = [
nixops.overlays.default
localOverlay
];
pkgs = import nixpkgs {
inherit system overlays;
};
src = nix-filter.lib.filter {
root = ./.;
include = with nix-filter.lib;[
(nix-filter.lib.matchExt "go")
./go.mod
./go.sum
./.golangci.yaml
./gqlgenc.yml
./controller/openapi.yaml
./image/image.c
./image/image.h
(inDirectory "migrations/postgres")
./gqlgenc.yml
isDirectory
(inDirectory "vendor")
(inDirectory "clamd/testdata")
(inDirectory "client/testdata")
(inDirectory "image/testdata")
(inDirectory "storage/testdata")
];
exclude = with nix-filter.lib; [
(inDirectory "build")
];
};
nix-src = nix-filter.lib.filter {
root = ./.;
include = [
(nix-filter.lib.matchExt "nix")
];
};
nixops-lib = nixops.lib { inherit pkgs; };
buildInputs = with pkgs; [
vips
];
nativeBuildInputs = with pkgs; [
go
clang
pkg-config
];
checkDeps = with pkgs; [
mockgen
gqlgenc
];
name = "hasura-storage";
version = "0.0.0-dev";
module = "github.com/nhost/hasura-storage";
tags = [ "integration" ];
ldflags = [
"-X ${module}/controller.buildVersion=${version}"
];
in
{
checks = {
nixpkgs-fmt = nixops-lib.nix.check { src = nix-src; };
go-checks = nixops-lib.go.check {
inherit src ldflags tags buildInputs nativeBuildInputs checkDeps;
preCheck = ''
export GIN_MODE=release
export HASURA_AUTH_BEARER=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE5ODAwNTYxNTAsImh0dHBzOi8vaGFzdXJhLmlvL2p3dC9jbGFpbXMiOnsieC1oYXN1cmEtYWxsb3dlZC1yb2xlcyI6WyJhZG1pbiJdLCJ4LWhhc3VyYS1kZWZhdWx0LXJvbGUiOiJhZG1pbiIsIngtaGFzdXJhLXVzZXItaWQiOiJhYjViYTU4ZS05MzJhLTQwZGMtODdlOC03MzM5OTg3OTRlYzIiLCJ4LWhhc3VyYS11c2VyLWlzQW5vbnltb3VzIjoiZmFsc2UifSwiaWF0IjoxNjY0Njk2MTUwLCJpc3MiOiJoYXN1cmEtYXV0aCIsInN1YiI6ImFiNWJhNThlLTkzMmEtNDBkYy04N2U4LTczMzk5ODc5NGVjMiJ9.OMVYu-30oOuUNZeSbzhP0u0pq5bf-U2Z49LWkqr3hyc
export TEST_S3_ACCESS_KEY=5a7bdb5f42c41e0622bf61d6e08d5537
export TEST_S3_SECRET_KEY=9e1c40c65a615a5b52f52aeeaf549944ec53acb1dff4a0bf01fb58e969f915c8
'';
};
};
devShells = flake-utils.lib.flattenTree rec {
default = nixops-lib.go.devShell {
buildInputs = with pkgs; [
go-migrate
ccls
] ++ buildInputs ++ nativeBuildInputs ++ checkDeps;
};
};
packages = flake-utils.lib.flattenTree rec {
hasuraStorage = nixops-lib.go.package {
inherit name src version ldflags buildInputs nativeBuildInputs;
};
docker-image = nixops-lib.go.docker-image {
inherit name version buildInputs;
package = hasuraStorage;
config = {
Env = [
"TMPDIR=/"
"MALLOC_ARENA_MAX=2"
];
};
};
clamav-docker-image = pkgs.dockerTools.buildLayeredImage {
name = "clamav";
tag = version;
created = "now";
contents = with pkgs; [
(writeTextFile {
name = "tmp-file";
text = ''
dummy file to generate tmpdir
'';
destination = "/tmp/tmp-file";
})
(writeTextFile {
name = "entrypoint.sh";
text = pkgs.lib.fileContents ./build/clamav/entrypoint.sh;
executable = true;
destination = "/usr/local/bin/entrypoint.sh";
})
(writeTextFile {
name = "freshclam.conf";
text = pkgs.lib.fileContents ./build/clamav/freshclam.conf.tmpl;
destination = "/etc/clamav/freshclam.conf.tmpl";
})
(writeTextFile {
name = "clamd.conf";
text = pkgs.lib.fileContents ./build/clamav/clamd.conf.tmpl;
destination = "/etc/clamav/clamd.conf.tmpl";
})
envsubst
clamav
fakeNss
dockerTools.caCertificates
] ++ lib.optionals stdenv.isLinux [
busybox
];
config = {
Env = [
"TMPDIR=/tmp"
];
Entrypoint = [
"/usr/local/bin/entrypoint.sh"
];
};
};
default = hasuraStorage;
};
}
);
}