-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathflake.nix
More file actions
131 lines (111 loc) · 3.81 KB
/
Copy pathflake.nix
File metadata and controls
131 lines (111 loc) · 3.81 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
{
description = "Wassette - A security-oriented runtime that runs WebAssembly Components via MCP";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, rust-overlay, flake-utils, crane, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
rustToolchain = (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml).override {
extensions = [ "rustfmt" "clippy" "rust-src" "rust-analyzer" ];
targets = [ "wasm32-wasip2" "wasm32-wasip1" "wasm32-unknown-unknown" ];
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
commonArgs = {
src = pkgs.lib.cleanSourceWith {
src = craneLib.path ./.;
filter = path: type:
(craneLib.filterCargoSources path type)
|| (pkgs.lib.hasSuffix ".wit" path)
|| (pkgs.lib.hasSuffix "README.md" path)
|| (pkgs.lib.hasSuffix "rust-toolchain.toml" path)
|| (pkgs.lib.hasSuffix "component-registry.json" path);
};
strictDeps = true;
buildInputs = with pkgs; [
openssl
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
];
nativeBuildInputs = with pkgs; [
pkg-config
rustToolchain
];
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
wassette = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
pname = "wassette";
version = (craneLib.crateNameFromCargoToml { inherit (commonArgs) src; }).version;
doCheck = false; # Tests require building wasm components which needs additional setup
});
in {
packages = {
default = wassette;
wassette = wassette;
};
devShells.default = pkgs.mkShell {
inputsFrom = [ wassette ];
packages = with pkgs; [
# Rust tooling
rustToolchain
cargo-watch
cargo-edit
cargo-expand
cargo-nextest
cargo-component
# Wasm tools
wasmtime
wasm-tools
wasm-pack
# Build tools
just
pkg-config
openssl
# Development tools
git
curl
jq
# Language support for examples
python3
nodejs_22
go
uv
];
shellHook = ''
echo "🚀 Wassette development environment"
echo ""
echo "Available commands:"
echo " cargo build - Build the project"
echo " cargo test - Run tests"
echo " cargo run - Run wassette"
echo " just - List available just recipes"
echo ""
echo "Rust toolchain: $(rustc --version)"
echo "Cargo component: $(cargo component --version 2>/dev/null || echo 'cargo-component is included in this dev shell (if this fails, check your environment)')"
echo ""
'';
RUST_BACKTRACE = 1;
RUST_LOG = "debug";
};
apps.default = flake-utils.lib.mkApp {
drv = wassette;
};
}
);
}