forked from openmeterio/openmeter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
240 lines (203 loc) · 8.25 KB
/
flake.nix
File metadata and controls
240 lines (203 loc) · 8.25 KB
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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
devenv.url = "github:cachix/devenv";
dagger.url = "github:dagger/nix";
dagger.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.devenv.flakeModule
];
systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ];
perSystem = { config, self', inputs', pkgs, lib, system, ... }: rec {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
(final: prev: {
dagger = inputs'.dagger.packages.dagger;
atlasx = self'.packages.atlasx;
})
];
};
devenv.shells = {
default =
let
corepack031 = pkgs.corepack.overrideAttrs (_: {
version = "0.31.0";
src = pkgs.fetchurl {
url = "https://registry.npmjs.org/corepack/-/corepack-0.31.0.tgz";
sha256 = "sha256-fGMkPPHeJV2BKJ+LRzzsVIwaltF2DAw2ltb9M2pj6xc=";
};
});
in
{
languages = {
go = {
enable = true;
package = pkgs.go_1_25;
};
python = {
enable = true;
package = pkgs.python314;
uv = {
enable = true;
};
};
javascript = {
enable = true;
package = pkgs.nodejs_22;
corepack = {
enable = true;
};
};
};
git-hooks.hooks = {
nixpkgs-fmt.enable = true;
commitizen.enable = true;
commitizen-branch = {
enable = true;
name = "commitizen-branch check";
description = ''
Check whether commit messages on the current HEAD follows committing rules.
'';
entry = "${pkgs.commitizen}/bin/cz check --allow-abort --rev-range origin/HEAD..HEAD";
pass_filenames = false;
stages = [ "manual" ];
};
};
packages = with pkgs; [
gnumake
mage
# Kafka build dependencies
# https://github.com/confluentinc/confluent-kafka-go#librdkafka
# Check actual version via:
# $ pkg-config --modversion rdkafka++
# Getting sha256 hash for git ref:
# $ nix-shell -p nix-prefetch-git jq --run "nix hash convert sha256:\$(nix-prefetch-git --url https://github.com/confluentinc/librdkafka.git --quiet --rev v2.11.1 | jq -r '.sha256')"
(rdkafka.overrideAttrs (_: rec {
version = "2.12.0";
src = fetchFromGitHub {
owner = "confluentinc";
repo = "librdkafka";
rev = "v${version}";
sha256 = "sha256-vL1kSn9I9vcDWLXRgLI5PaEwgpowBtSS/oqQZAU6wJ0=";
};
}))
cyrus_sasl
pkg-config
# confluent-platform
golangci-lint
goreleaser
air
curl
jq
minikube
kind
kubectl
helm-docs
kubernetes-helm
benthos
# We should use a custom light-weight derivation, see this thread https://discourse.nixos.org/t/installing-postgresql-client/948/15
# Multi-platform support makes this a bit more difficult
postgresql
# node
nodePackages.pnpm
corepack031
# We can consider adding a pkgs.buildNpmPackage for spectral-cli if build takes a lot of time, but for now
# this is a quick fix to get it working.
(writeShellScriptBin "spectral" ''
exec ${pkgs.nodejs_22}/bin/npx -y @stoplight/spectral-cli@6.13.1 "$@"
'')
# python
poetry
atlasx
just
semver-tool
dagger
go-migrate
sqlc
];
enterShell = ''
# Put Corepack 0.31.0 first on PATH
export PATH="${corepack031}/bin:$PATH"
# Disable download prompt for corepack
export COREPACK_ENABLE_DOWNLOAD_PROMPT=0
'';
env = {
KUBECONFIG = "${config.devenv.shells.default.env.DEVENV_STATE}/kube/config";
KIND_CLUSTER_NAME = "openmeter";
HELM_CACHE_HOME = "${config.devenv.shells.default.env.DEVENV_STATE}/helm/cache";
HELM_CONFIG_HOME = "${config.devenv.shells.default.env.DEVENV_STATE}/helm/config";
HELM_DATA_HOME = "${config.devenv.shells.default.env.DEVENV_STATE}/helm/data";
PATH = lib.mkBefore "${
(pkgs.corepack.overrideAttrs (_: {
version = "0.31.0";
src = pkgs.fetchurl {
url = "https://registry.npmjs.org/corepack/-/corepack-0.31.0.tgz";
sha256 = "sha256-fGMkPPHeJV2BKJ+LRzzsVIwaltF2DAw2ltb9M2pj6xc=";
};
}))
}/bin";
};
# https://github.com/cachix/devenv/issues/528#issuecomment-1556108767
containers = pkgs.lib.mkForce { };
};
ci = devenv.shells.default;
# Lighteweight target to use inside dagger
dagger = {
languages = {
go = devenv.shells.default.languages.go;
};
packages = with pkgs; [
gnumake
git
atlasx
];
containers = devenv.shells.default.containers;
};
};
packages = {
atlasx =
let
systemMappings = {
x86_64-linux = "linux-amd64";
x86_64-darwin = "darwin-amd64";
aarch64-darwin = "darwin-arm64";
aarch64-linux = "linux-arm64";
};
# nix hash convert --hash-algo sha256 --to sri SHA256SUM
hashMappings = {
# nix hash convert --hash-algo sha256 --to sri "$(curl -sfL 'https://release.ariga.io/atlas/atlas-linux-amd64-v'"${VERSION}"'.sha256')"
x86_64-linux = "sha256-2IquGGpV5Yk8MY87Ecg4ozcq302sHi/TvH0rVZRMV5c=";
# nix hash convert --hash-algo sha256 --to sri "$(curl -sfL 'https://release.ariga.io/atlas/atlas-darwin-amd64-v'"${VERSION}"'.sha256')"
x86_64-darwin = "sha256-yMvFQ32wVAXpzXEN+hC8nTkr+2eqoWBhT92JqXBUusQ=";
# nix hash convert --hash-algo sha256 --to sri "$(curl -sfL 'https://release.ariga.io/atlas/atlas-darwin-arm64-v'"${VERSION}"'.sha256')"
aarch64-darwin = "sha256-mP7mg4RyqdL5D5FFNEna6aWs/cEsNq/vrmdiX78/EP0=";
# nix hash convert --hash-algo sha256 --to sri "$(curl -sfL 'https://release.ariga.io/atlas/atlas-linux-arm64-v'"${VERSION}"'.sha256')"
aarch64-linux = "sha256-u4oioIzNmmy5PwoWIFt7vrBn3X/sH2AifGh9jek9YIg=";
};
in
pkgs.stdenv.mkDerivation rec {
pname = "atlasx";
version = "0.36.0";
src = pkgs.fetchurl {
# License: https://ariga.io/legal/atlas/eula/eula-20240804.pdf
url = "https://release.ariga.io/atlas/atlas-${systemMappings."${system}"}-v${version}";
hash = hashMappings."${system}";
};
unpackPhase = ''
cp $src atlas
'';
installPhase = ''
mkdir -p $out/bin
cp atlas $out/bin/atlas
chmod +x $out/bin/atlas
'';
};
};
};
};
}