forked from agentclientprotocol/agent-client-protocol
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathflake.nix
More file actions
78 lines (67 loc) · 2.37 KB
/
flake.nix
File metadata and controls
78 lines (67 loc) · 2.37 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
{
description = "Devshell for ACP";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs =
{
self,
nixpkgs,
flake-utils,
rust-overlay,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
formatter = pkgs.nixfmt-rfc-style;
# Use rustup to manage toolchains so `cargo +nightly` works in dev shell
rustup = pkgs.rustup;
in
{
inherit formatter;
devShells.default = pkgs.mkShell {
packages = with pkgs; [
# Rustup manages stable/nightly toolchains according to rust-toolchain.toml
rustup
pkg-config
openssl
# Node.js toolchain
nodejs_24
# Go toolchain
go_1_24
# Nix formatter
formatter
];
RUST_BACKTRACE = "1";
# Ensure rustup shims are used and install required toolchains on first entry
shellHook = ''
export RUSTUP_HOME="$PWD/.rustup"
export CARGO_HOME="$PWD/.cargo"
export PATH="$CARGO_HOME/bin:$PATH"
if ! command -v rustup >/dev/null 2>&1; then
echo "rustup not found in PATH" 1>&2
else
# Install toolchains if missing; respect pinned channel from rust-toolchain.toml
if ! rustup toolchain list | grep -q nightly; then
rustup toolchain install nightly --profile minimal >/dev/null 2>&1 || true
fi
# Ensure stable toolchain from rust-toolchain.toml exists (rustup will auto-select it)
# Attempt to install channel specified in rust-toolchain.toml (fallback to stable)
TOOLCHAIN_CHANNEL=$(sed -n 's/^channel\s*=\s*"\(.*\)"/\1/p' rust-toolchain.toml || true)
if [ -n "$TOOLCHAIN_CHANNEL" ]; then
if ! rustup toolchain list | grep -q "$TOOLCHAIN_CHANNEL"; then
rustup toolchain install "$TOOLCHAIN_CHANNEL" --profile minimal --component rustfmt clippy >/dev/null 2>&1 || true
fi
fi
fi
'';
};
}
);
}