-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
219 lines (184 loc) · 7.83 KB
/
Copy pathflake.nix
File metadata and controls
219 lines (184 loc) · 7.83 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
devenv.url = "github:cachix/devenv";
git-hooks.url = "github:cachix/git-hooks.nix";
pre-commit-hooks.follows = "git-hooks";
};
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: {
atlasx = self'.packages.atlasx;
})
];
};
devenv.shells = {
default = {
languages = {
go = {
enable = true;
package = pkgs.go_1_26;
};
python = {
enable = true;
package = pkgs.python314;
uv = {
enable = true;
};
};
javascript = {
enable = true;
package = pkgs.nodejs-slim_26;
pnpm = {
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" ];
};
};
# Use alternative pre-commit implementations
git-hooks.package = pkgs.prek;
packages = with pkgs; [
git
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.15.0 | jq -r '.sha256')"
(rdkafka.overrideAttrs (_: rec {
src = fetchFromGitHub {
owner = "confluentinc";
repo = "librdkafka";
rev = "v2.15.0";
sha256 = "sha256-WW64fwh0xR4lEVwmrv00tP9mo6b49aCNgLLH/P0YS8k=";
};
}))
cyrus_sasl
pkg-config
# confluent-platform
golangci-lint
goreleaser
gotestsum
air
curl
jq
yq-go
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: pnpm (from javascript.pnpm) provides `pnpm dlx` as the
# npx-style runner for these one-off CLIs. The invoked bin runs
# under the dev shell's `node` (nodejs-slim_26) via its env-node
# shebang, so no separate corepack/Node runtime is needed.
# 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.pnpm}/bin/pnpm dlx @stoplight/spectral-cli@6.16.0 "$@"
'')
(writeShellScriptBin "codegraph" ''
exec ${pkgs.pnpm}/bin/pnpm dlx @colbymchenry/codegraph@1.2.0 "$@"
'')
# python
poetry
atlasx
just
semver-tool
go-migrate
sqlc
];
env = {
KUBECONFIG = "${config.devenv.shells.default.env.DEVENV_STATE}/kube/config";
KIND_CLUSTER_NAME = "meterforge";
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";
};
enterShell = ''
${lib.optionalString pkgs.stdenv.isDarwin ''
# Workaround for XCBUILD.XCRUN cosmetic issue due to incompatible plists (see https://github.com/NixOS/nixpkgs/issues/376958)
# 1) Filter out the buggy Nix version of xcbuild/xcrun from PATH
export PATH=$(echo "$PATH" | tr ':' '\n' | grep -v "xcbuild" | tr '\n' ':')
# 2) Force the system to use the Apple SDK path if needed
unset DEVELOPER_DIR
# End of workaround
''}
# Keep GitHub-hosted Node jobs aligned with the Nix shell.
node -v > .nvmrc
'';
# https://github.com/cachix/devenv/issues/528#issuecomment-1556108767
containers = pkgs.lib.mkForce { };
};
ci = devenv.shells.default;
};
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."${pkgs.stdenv.hostPlatform.system}"}-v${version}";
hash = hashMappings."${pkgs.stdenv.hostPlatform.system}";
};
unpackPhase = ''
cp $src atlas
'';
installPhase = ''
mkdir -p $out/bin
cp atlas $out/bin/atlas
chmod +x $out/bin/atlas
'';
};
};
};
};
}