Skip to content

Commit d5afb19

Browse files
committed
more packages
1 parent 331e528 commit d5afb19

8 files changed

Lines changed: 328 additions & 6 deletions

File tree

.github/workflows/nix-build.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Nix Build (experimental)
22

33
on:
44
push:
5-
branches: [canary]
5+
branches: [canary, greg/new-flake]
66
pull_request:
77

88
concurrency:
@@ -21,7 +21,7 @@ jobs:
2121

2222
- uses: cachix/cachix-action@v15
2323
with:
24-
name: baml
24+
name: boundaryml
2525
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
2626

2727
- name: Build CLI
@@ -41,7 +41,7 @@ jobs:
4141

4242
- uses: cachix/cachix-action@v15
4343
with:
44-
name: baml
44+
name: boundaryml
4545
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
4646

4747
- name: Build CLI

engine/baml-runtime/src/cli/init_ui.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl InitUI {
107107
Line::from(vec![
108108
Span::raw(" "),
109109
Span::styled(
110-
"🚀 Setting up BAML for you!",
110+
"🚀 Setting up BAML for you!!",
111111
Style::default()
112112
.fg(PURPLE_COLOR)
113113
.add_modifier(Modifier::BOLD),

flake.nix

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,77 @@
103103
bamlRustPackage = cliPkgs.bamlRustPackage;
104104
};
105105

106+
# wasm-bindgen-cli pinned to match Cargo.lock (nixpkgs has 0.2.100, we need 0.2.105)
107+
wasm-bindgen-cli = import ./nix/lib/wasm-bindgen-cli.nix { inherit pkgs; };
108+
106109
wasmPkgs = import ./nix/packages/baml-wasm.nix {
107110
inherit
108111
crane
109112
pkgs
110113
toolchain
111114
src
112115
version
116+
wasm-bindgen-cli
117+
;
118+
};
119+
120+
# --- Shared pnpm workspace source + deps (used by JS/TS packages) ---
121+
122+
pnpmSrc = pkgs.lib.cleanSourceWith {
123+
src = ./.;
124+
filter =
125+
path: type:
126+
let
127+
baseName = baseNameOf path;
128+
in
129+
baseName != "node_modules"
130+
&& baseName != "result"
131+
&& baseName != ".jj"
132+
&& baseName != ".git"
133+
&& baseName != ".claude"
134+
&& !pkgs.lib.hasInfix "/target/" path
135+
&& !pkgs.lib.hasSuffix ".so" baseName
136+
&& !pkgs.lib.hasSuffix ".node" baseName
137+
&& !pkgs.lib.hasSuffix ".vsix" baseName;
138+
};
139+
140+
# Single pnpm dependency fetch shared by all JS/TS packages
141+
pnpmDeps = pkgs.pnpm_9.fetchDeps {
142+
pname = "baml-workspace";
143+
inherit version;
144+
src = pnpmSrc;
145+
hash = "sha256-PjYsVup7GLEHMvUN47OYcurkAYR0xUQPAr1NNyX+oe8=";
146+
fetcherVersion = 2;
147+
};
148+
149+
codemirrorLangBaml = import ./nix/packages/codemirror-lang-baml.nix {
150+
inherit pkgs pkgs-unstable version pnpmDeps;
151+
src = pnpmSrc;
152+
};
153+
154+
fiddleFrontend = import ./nix/packages/fiddle-frontend.nix {
155+
inherit
156+
pkgs
157+
pkgs-unstable
158+
version
159+
pnpmDeps
113160
;
161+
src = pnpmSrc;
162+
baml-schema-wasm = wasmPkgs.baml-schema-wasm;
163+
codemirror-lang-baml = codemirrorLangBaml;
164+
};
165+
166+
bamlVsix = import ./nix/packages/baml-vsix.nix {
167+
inherit
168+
pkgs
169+
pkgs-unstable
170+
version
171+
pnpmDeps
172+
;
173+
src = pnpmSrc;
174+
baml-schema-wasm = wasmPkgs.baml-schema-wasm;
175+
baml-cli = cliPkgs.release;
176+
codemirror-lang-baml = codemirrorLangBaml;
114177
};
115178

116179
in
@@ -189,6 +252,11 @@
189252

190253
# WASM package
191254
baml-schema-wasm = wasmPkgs.baml-schema-wasm;
255+
256+
# Frontend / extension packages
257+
codemirror-lang-baml = codemirrorLangBaml;
258+
fiddle-frontend = fiddleFrontend;
259+
baml-vsix = bamlVsix;
192260
};
193261

194262
# --- Checks (intermediates exposed for Cachix caching) ---

nix/lib/wasm-bindgen-cli.nix

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Build wasm-bindgen-cli from source at the exact version matching Cargo.lock.
2+
#
3+
# The nixpkgs wasm-bindgen-cli (0.2.100) doesn't match the workspace's
4+
# wasm-bindgen crate (=0.2.105). wasm-bindgen requires an exact version match
5+
# between the CLI and the crate, so we build from source.
6+
#
7+
# To update: change `version`, then run `nix build .#baml-schema-wasm`.
8+
# Nix will error twice with the correct hashes — update `hash` first, then `cargoHash`.
9+
{ pkgs }:
10+
11+
pkgs.rustPlatform.buildRustPackage rec {
12+
pname = "wasm-bindgen-cli";
13+
version = "0.2.105";
14+
15+
src = pkgs.fetchCrate {
16+
inherit pname version;
17+
hash = "sha256-zLPFFgnqAWq5R2KkaTGAYqVQswfBEYm9x3OPjx8DJRY=";
18+
};
19+
20+
cargoHash = "sha256-a2X9bzwnMWNt0fTf30qAiJ4noal/ET1jEtf5fBFj5OU=";
21+
22+
nativeBuildInputs = [ pkgs.pkg-config ];
23+
24+
buildInputs = [ pkgs.openssl ]
25+
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
26+
pkgs.curl
27+
];
28+
29+
doCheck = false;
30+
31+
meta = with pkgs.lib; {
32+
description = "CLI tool for wasm-bindgen (pinned to match workspace Cargo.lock)";
33+
homepage = "https://rustwasm.github.io/wasm-bindgen/";
34+
license = with licenses; [ mit asl20 ];
35+
};
36+
}

nix/packages/baml-vsix.nix

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# BAML VS Code extension (.vsix package)
2+
#
3+
# Builds the baml-extension VSIX which bundles:
4+
# - The language server extension (tsup-compiled)
5+
# - The playground webview (Vite-built fiddle-frontend)
6+
# - The baml-cli binary
7+
#
8+
# To update pnpmDeps hash: same as fiddle-frontend.
9+
{
10+
pkgs,
11+
pkgs-unstable,
12+
version,
13+
src,
14+
pnpmDeps,
15+
baml-schema-wasm,
16+
baml-cli,
17+
codemirror-lang-baml,
18+
}:
19+
20+
pkgs.stdenvNoCC.mkDerivation {
21+
pname = "baml-vsix";
22+
inherit version src;
23+
24+
nativeBuildInputs = [
25+
pkgs.pnpm_9.configHook
26+
pkgs-unstable.nodejs_20
27+
pkgs.vsce
28+
];
29+
30+
inherit pnpmDeps;
31+
32+
preBuild = ''
33+
# Place WASM output where vite expects it
34+
mkdir -p engine/baml-schema-wasm/web/dist
35+
cp -r ${baml-schema-wasm}/pkg/* engine/baml-schema-wasm/web/dist/
36+
37+
# Place pre-built codemirror-lang-baml
38+
mkdir -p typescript/packages/codemirror-lang-baml/dist
39+
cp -r ${codemirror-lang-baml}/* typescript/packages/codemirror-lang-baml/dist/
40+
'';
41+
42+
buildPhase = ''
43+
runHook preBuild
44+
45+
# Build @baml/playground and all its transitive workspace dependencies
46+
pnpm --filter "...@baml/playground" build
47+
48+
# Place playground dist into vscode-ext/dist/playground
49+
mkdir -p typescript/apps/vscode-ext/dist/playground
50+
cp -r typescript/apps/playground/dist/* typescript/apps/vscode-ext/dist/playground/
51+
52+
# Place CLI binary
53+
mkdir -p typescript/apps/vscode-ext/dist
54+
cp ${baml-cli}/bin/baml-cli typescript/apps/vscode-ext/dist/baml-cli
55+
56+
# Build the extension with tsup
57+
cd typescript/apps/vscode-ext
58+
CI=true pnpm run build
59+
60+
# Package as VSIX
61+
vsce package --no-dependencies
62+
63+
runHook postBuild
64+
'';
65+
66+
installPhase = ''
67+
mkdir -p $out
68+
cp *.vsix $out/
69+
'';
70+
71+
meta = with pkgs.lib; {
72+
description = "BAML VS Code extension (.vsix)";
73+
homepage = "https://github.com/boundaryml/baml";
74+
license = licenses.mit;
75+
};
76+
}

nix/packages/baml-wasm.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
toolchain,
66
src,
77
version,
8+
wasm-bindgen-cli,
89
}:
910

1011
let
@@ -29,8 +30,7 @@ let
2930
cargoExtraArgs = "-p baml-schema-build";
3031

3132
nativeBuildInputs = [
32-
pkgs.wasm-pack
33-
pkgs.wasm-bindgen-cli
33+
wasm-bindgen-cli
3434
];
3535

3636
# Skip default install (cargo install doesn't work for cdylib wasm targets)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# @baml/codemirror-lang-baml — Lezer grammar + tsup build
2+
#
3+
# Built separately so fiddle-frontend and baml-vsix can depend on
4+
# the pre-built dist/ without worrying about build ordering.
5+
{
6+
pkgs,
7+
pkgs-unstable,
8+
version,
9+
src,
10+
pnpmDeps,
11+
}:
12+
13+
let
14+
nodejs = pkgs-unstable.nodejs_20;
15+
16+
in
17+
pkgs.stdenvNoCC.mkDerivation {
18+
pname = "codemirror-lang-baml";
19+
inherit version src;
20+
21+
nativeBuildInputs = [
22+
pkgs.pnpm_9.configHook
23+
nodejs
24+
];
25+
26+
inherit pnpmDeps;
27+
28+
buildPhase = ''
29+
runHook preBuild
30+
pnpm --filter @baml/codemirror-lang-baml build
31+
runHook postBuild
32+
'';
33+
34+
installPhase = ''
35+
mkdir -p $out
36+
cp -r typescript/packages/codemirror-lang-baml/dist/* $out/
37+
'';
38+
39+
meta = with pkgs.lib; {
40+
description = "BAML language support for CodeMirror (Lezer grammar)";
41+
homepage = "https://github.com/boundaryml/baml";
42+
license = licenses.mit;
43+
};
44+
}

0 commit comments

Comments
 (0)