-
Notifications
You must be signed in to change notification settings - Fork 42
/
flake.nix
132 lines (117 loc) · 3.48 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
{
# Nix: https://nixos.org/download.html
# How to activate flakes: https://nixos.wiki/wiki/Flakes
# For seamless integration, consider using:
# - direnv: https://github.com/direnv/direnv
# - nix-direnv: https://github.com/nix-community/nix-direnv
#
# # .envrc
# use flake
# dotenv .env
#
description = "Grafbase CLI development environment";
inputs = {
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = inputs @ {
flake-parts,
nixpkgs,
flake-utils,
crane,
rust-overlay,
...
}: let
inherit (nixpkgs.lib) optional concatStringsSep;
systems = flake-utils.lib.system;
flake = flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
};
aarch64DarwinExternalCargoCrates = concatStringsSep " " ["[email protected]" "[email protected]"];
defaultShellConf = {
nativeBuildInputs = with pkgs;
[
# Testing
cargo-insta
cargo-nextest
# Benchmark tool to send multiple requests
hey
# binary bloat inspector
cargo-bloat
# Versioning, automation and releasing
cargo-make
cargo-release
nodePackages.npm
nodePackages.semver
sd
# Node.js
nodejs
nodePackages.prettier
bun # for wrappers
# Native SSL
openssl
pkg-config
cmake # for libz-ng-sys
# Rust
rustup
# SQLx macros
libiconv
# Resolver tests
nodePackages.pnpm
nodePackages.yarn
]
++ optional (system == systems.aarch64-darwin) [
cargo-binstall
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.CoreServices
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
]
++ optional (system != systems.aarch64-darwin) [
cargo-about # broken build at the moment on darwin
];
shellHook = ''
project_root="$(git rev-parse --show-toplevel 2>/dev/null || jj workspace root 2>/dev/null)"
export CARGO_INSTALL_ROOT="$project_root/cli/.cargo";
export PATH="$CARGO_INSTALL_ROOT/bin:$project_root/node_modules/.bin:$PATH";
if [[ "${system}" == "aarch64-darwin" ]]; then
cargo binstall --no-confirm --no-symlinks --quiet ${aarch64DarwinExternalCargoCrates}
fi
'';
};
in {
devShells.default = pkgs.mkShell defaultShellConf;
});
in
flake-parts.lib.mkFlake {inherit inputs;} {
inherit flake;
systems = flake-utils.lib.defaultSystems;
perSystem = {
config,
system,
...
}: {
_module.args = {
inherit crane;
pkgs = import nixpkgs {
inherit system;
overlays = [(import rust-overlay)];
};
};
imports = [./cli/nix/cli.nix];
};
};
}