nandi/gleanpublic Fork 0
b954666
Commits
Clone
git clone https://git.rickub.com/nandi/glean.git
git clone ssh://git@rickub.com/nandi/glean.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Replace Dockerfile with a buck2 :image target built via Nix dockerTools

Adds flake.nix defining the Go API binary (buildGoModule), the SvelteKit
frontend (bun install/build split into a fixed-output deps fetch + sandboxed
build), and a dockerTools.streamLayeredImage assembling both.

Since this dev machine has no `nix` installed, the actual build happens on
a remote host (nix-vm) over SSH: buck2's :image genrule declares the whole
repo as srcs, and scripts/build-image.sh (kept separate so the genrule stays
a thin, side-effect-free wrapper) rsyncs $SRCDIR to nix-vm, runs `nix build
.#image` there, and streams the resulting docker-archive tar back into $OUT.

Drops the Dockerfile/.dockerignore it replaces.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
nandi committed 2026-08-21T12:33:56-07:00 Browse files
b954666 parent: 0fd82a4
added .buckconfig +29 -0
new file mode 100644
@@ -0,0 +1,29 @@
1+[cells]
2+ root = .
3+ prelude = prelude
4+ toolchains = toolchains
5+ none = none
6+
7+[cell_aliases]
8+ config = prelude
9+ ovr_config = prelude
10+ fbcode = none
11+ fbsource = none
12+ fbcode_macros = none
13+ buck = none
14+
15+# Uses a copy of the prelude bundled with the buck2 binary. You can alternatively delete this
16+# section and vendor a copy of the prelude to the `prelude` directory of your project.
17+[external_cells]
18+ prelude = bundled
19+
20+[parser]
21+ target_platform_detector_spec = target:root//...->prelude//platforms:default \
22+ target:prelude//...->prelude//platforms:default \
23+ target:toolchains//...->prelude//platforms:default
24+
25+[build]
26+ execution_platforms = prelude//platforms:default
27+
28+[project]
29+ ignore = .git, web/node_modules, web/.svelte-kit, web/build
new file mode 100644
@@ -0,0 +1,29 @@
1+[cells]
2+ root = .
3+ prelude = prelude
4+ toolchains = toolchains
5+ none = none
6+
7+[cell_aliases]
8+ config = prelude
9+ ovr_config = prelude
10+ fbcode = none
11+ fbsource = none
12+ fbcode_macros = none
13+ buck = none
14+
15+# Uses a copy of the prelude bundled with the buck2 binary. You can alternatively delete this
16+# section and vendor a copy of the prelude to the `prelude` directory of your project.
17+[external_cells]
18+ prelude = bundled
19+
20+[parser]
21+ target_platform_detector_spec = target:root//...->prelude//platforms:default \
22+ target:prelude//...->prelude//platforms:default \
23+ target:toolchains//...->prelude//platforms:default
24+
25+[build]
26+ execution_platforms = prelude//platforms:default
27+
28+[project]
29+ ignore = .git, web/node_modules, web/.svelte-kit, web/build
added .buckroot +0 -0
new file mode 100644
new file mode 100644
deleted .dockerignore +0 -4
deleted file mode 100644
@@ -1,4 +0,0 @@
1-.git
2-.env
3-node_modules
4-glean.db
deleted file mode 100644
@@ -1,4 +0,0 @@
1-.git
2-.env
3-node_modules
4-glean.db
modified .gitignore +3 -0
@@ -31,5 +31,8 @@ web/node_modules/
3131 web/build/
3232 web/.svelte-kit/
3333
34+# buck2
35+/buck-out
36+
3437 # todo
3538 todo.md
@@ -31,5 +31,8 @@ web/node_modules/
31 web/build/31 web/build/
32 web/.svelte-kit/32 web/.svelte-kit/
33 33
34+# buck2
35+/buck-out
36+
34 # todo37 # todo
35 todo.md38 todo.md
added BUCK +30 -0
new file mode 100644
@@ -0,0 +1,30 @@
1+# A list of available rules and their signatures can be found here: https://buck2.build/docs/prelude/globals/
2+
3+export_file(
4+ name = "build_image_sh",
5+ src = "scripts/build-image.sh",
6+)
7+
8+# Builds the glean container image via Nix's dockerTools.streamLayeredImage
9+# (see flake.nix), executed on the remote `nix-vm` builder over SSH -- this
10+# machine has no `nix` installed. The genrule itself stays a thin, uninvolved
11+# wrapper; all the actual rsync/ssh side effects live in build-image.sh.
12+genrule(
13+ name = "image",
14+ out = "glean-image.tar",
15+ # Populates $SRCDIR with a symlink farm mirroring the whole repo tree
16+ # (minus buck-out/.git/node_modules) -- build-image.sh rsyncs it to the
17+ # remote nix-vm builder, since it needs the full source, not just this
18+ # target's declared deps.
19+ srcs = glob(
20+ ["**/*"],
21+ exclude = [
22+ "buck-out/**",
23+ ".git/**",
24+ "web/node_modules/**",
25+ "web/.svelte-kit/**",
26+ "web/build/**",
27+ ],
28+ ),
29+ cmd = "chmod +x $(location :build_image_sh) && $(location :build_image_sh) $SRCDIR $OUT",
30+)
new file mode 100644
@@ -0,0 +1,30 @@
1+# A list of available rules and their signatures can be found here: https://buck2.build/docs/prelude/globals/
2+
3+export_file(
4+ name = "build_image_sh",
5+ src = "scripts/build-image.sh",
6+)
7+
8+# Builds the glean container image via Nix's dockerTools.streamLayeredImage
9+# (see flake.nix), executed on the remote `nix-vm` builder over SSH -- this
10+# machine has no `nix` installed. The genrule itself stays a thin, uninvolved
11+# wrapper; all the actual rsync/ssh side effects live in build-image.sh.
12+genrule(
13+ name = "image",
14+ out = "glean-image.tar",
15+ # Populates $SRCDIR with a symlink farm mirroring the whole repo tree
16+ # (minus buck-out/.git/node_modules) -- build-image.sh rsyncs it to the
17+ # remote nix-vm builder, since it needs the full source, not just this
18+ # target's declared deps.
19+ srcs = glob(
20+ ["**/*"],
21+ exclude = [
22+ "buck-out/**",
23+ ".git/**",
24+ "web/node_modules/**",
25+ "web/.svelte-kit/**",
26+ "web/build/**",
27+ ],
28+ ),
29+ cmd = "chmod +x $(location :build_image_sh) && $(location :build_image_sh) $SRCDIR $OUT",
30+)
deleted Dockerfile +0 -43
deleted file mode 100644
@@ -1,43 +0,0 @@
1-FROM golang:1.26-alpine AS builder
2-
3-RUN apk add --no-cache gcc musl-dev nodejs npm && \
4- npm install -g bun
5-
6-WORKDIR /src
7-COPY go.mod go.sum ./
8-RUN go mod download
9-
10-COPY web/package.json web/bun.lock* ./web/
11-RUN cd web && bun install --frozen-lockfile
12-
13-COPY . .
14-
15-# Build the SvelteKit frontend (SSR via adapter-node).
16-RUN cd web && bun run build
17-
18-# Build the Go API binary.
19-RUN --mount=type=cache,target=/root/.cache/go-build \
20- CGO_CFLAGS="-I/src/internal/db/include -I$(go env GOMODCACHE)/github.com/mattn/go-sqlite3@$(grep 'mattn/go-sqlite3' go.mod | awk '{print $2}') -Du_int8_t=uint8_t -Du_int16_t=uint16_t -Du_int64_t=uint64_t" \
21- CGO_ENABLED=1 go build -tags fts5 -ldflags="-s -w" -o /glean .
22-
23-FROM node:22-alpine
24-
25-RUN apk add --no-cache ca-certificates
26-
27-# Go API binary.
28-COPY --from=builder /glean /usr/local/bin/glean
29-
30-# SvelteKit SSR build output.
31-COPY --from=builder /src/web/build /app/web/build
32-COPY --from=builder /src/web/package.json /app/web/package.json
33-
34-WORKDIR /app/web
35-
36-# SvelteKit proxies /api to the Go API on localhost:8080.
37-ENV GLEAN_API_URL=http://127.0.0.1:8080
38-ENV PORT=3000
39-
40-EXPOSE 3000
41-
42-# Run the Go API in the background, then the SvelteKit Node server in front.
43-CMD ["sh", "-c", "GLEAN_API_URL=http://127.0.0.1:8080 GLEAN_ADDR=127.0.0.1:8080 glean & GO_PID=$!; trap 'kill $GO_PID' INT TERM; exec node build/index.js"]
deleted file mode 100644
@@ -1,43 +0,0 @@
1-FROM golang:1.26-alpine AS builder
2-
3-RUN apk add --no-cache gcc musl-dev nodejs npm && \
4- npm install -g bun
5-
6-WORKDIR /src
7-COPY go.mod go.sum ./
8-RUN go mod download
9-
10-COPY web/package.json web/bun.lock* ./web/
11-RUN cd web && bun install --frozen-lockfile
12-
13-COPY . .
14-
15-# Build the SvelteKit frontend (SSR via adapter-node).
16-RUN cd web && bun run build
17-
18-# Build the Go API binary.
19-RUN --mount=type=cache,target=/root/.cache/go-build \
20- CGO_CFLAGS="-I/src/internal/db/include -I$(go env GOMODCACHE)/github.com/mattn/go-sqlite3@$(grep 'mattn/go-sqlite3' go.mod | awk '{print $2}') -Du_int8_t=uint8_t -Du_int16_t=uint16_t -Du_int64_t=uint64_t" \
21- CGO_ENABLED=1 go build -tags fts5 -ldflags="-s -w" -o /glean .
22-
23-FROM node:22-alpine
24-
25-RUN apk add --no-cache ca-certificates
26-
27-# Go API binary.
28-COPY --from=builder /glean /usr/local/bin/glean
29-
30-# SvelteKit SSR build output.
31-COPY --from=builder /src/web/build /app/web/build
32-COPY --from=builder /src/web/package.json /app/web/package.json
33-
34-WORKDIR /app/web
35-
36-# SvelteKit proxies /api to the Go API on localhost:8080.
37-ENV GLEAN_API_URL=http://127.0.0.1:8080
38-ENV PORT=3000
39-
40-EXPOSE 3000
41-
42-# Run the Go API in the background, then the SvelteKit Node server in front.
43-CMD ["sh", "-c", "GLEAN_API_URL=http://127.0.0.1:8080 GLEAN_ADDR=127.0.0.1:8080 glean & GO_PID=$!; trap 'kill $GO_PID' INT TERM; exec node build/index.js"]
added flake.nix +121 -0
new file mode 100644
@@ -0,0 +1,121 @@
1+{
2+ description = "glean: Go API + SvelteKit frontend, packaged as a container image via dockerTools";
3+
4+ inputs = {
5+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+ };
7+
8+ outputs = { self, nixpkgs }:
9+ let
10+ system = "x86_64-linux";
11+ pkgs = import nixpkgs { inherit system; };
12+ lib = pkgs.lib;
13+
14+ # --- Go API binary -----------------------------------------------------
15+ # Mirrors the Dockerfile's CGO setup: mattn/go-sqlite3 vendors its own
16+ # sqlite3 amalgamation, but sqlite-vec-go-bindings' cgo code expects a
17+ # plain `sqlite3.h` on the include path. internal/db/include/sqlite3.h
18+ # is that header; go-sqlite3's own module dir is added too so the
19+ # u_intN_t compat defines line up with the same sqlite3 version.
20+ glean = pkgs.buildGoModule {
21+ pname = "glean";
22+ version = "0.0.1";
23+ src = ./.;
24+ vendorHash = "sha256-EYJD4hBs4RT9Qwccqw0G58Hdn7TtJKfSAL4CHQVLXO0=";
25+
26+ env.CGO_ENABLED = "1";
27+ tags = [ "fts5" ];
28+ ldflags = [ "-s" "-w" ];
29+
30+ # buildGoModule builds with `-mod=vendor` against a `vendor/` tree it
31+ # generates itself (that's what vendorHash actually pins), so the
32+ # go-sqlite3 header lives under vendor/, not $(go env GOMODCACHE).
33+ preBuild = ''
34+ export CGO_CFLAGS="-I$PWD/internal/db/include -I$PWD/vendor/github.com/mattn/go-sqlite3 -Du_int8_t=uint8_t -Du_int16_t=uint16_t -Du_int64_t=uint64_t"
35+ '';
36+
37+ doCheck = false;
38+ };
39+
40+ # --- SvelteKit frontend (adapter-node) ---------------------------------
41+ # bun install needs network access, which the nix sandbox forbids for a
42+ # normal derivation -- split into a fixed-output "fetch deps" step
43+ # (network allowed, output hash pinned) and a sandboxed "build" step
44+ # that only ever sees the already-fetched node_modules.
45+ webDeps = pkgs.stdenvNoCC.mkDerivation {
46+ pname = "glean-web-deps";
47+ version = "0.0.1";
48+ src = ./web;
49+ nativeBuildInputs = [ pkgs.bun pkgs.cacert ];
50+
51+ buildPhase = ''
52+ export HOME=$TMPDIR
53+ export SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
54+ bun install --frozen-lockfile
55+ '';
56+ installPhase = ''
57+ mkdir -p $out
58+ cp -r node_modules $out/node_modules
59+ '';
60+
61+ outputHashMode = "recursive";
62+ outputHashAlgo = "sha256";
63+ outputHash = "sha256-q/VJbH1rWCsxf3A3RYb22t2RrtjUm4xCCrCZkLkAFFY=";
64+ };
65+
66+ frontend = pkgs.stdenvNoCC.mkDerivation {
67+ pname = "glean-web";
68+ version = "0.0.1";
69+ src = ./web;
70+ # nodejs_22 is needed so patchShebangs below has a `node` binary on
71+ # PATH to point node_modules/.bin scripts' shebangs at.
72+ nativeBuildInputs = [ pkgs.bun pkgs.nodejs_22 ];
73+
74+ buildPhase = ''
75+ export HOME=$TMPDIR
76+ cp -r ${webDeps}/node_modules .
77+ chmod -R u+w node_modules
78+ # node_modules/.bin scripts have `#!/usr/bin/env node` shebangs;
79+ # /usr/bin/env doesn't exist inside the nix sandbox, so patch them
80+ # to point at the real node on the store path.
81+ patchShebangs node_modules
82+ bun run build
83+ '';
84+ installPhase = ''
85+ mkdir -p $out
86+ cp -r build $out/build
87+ cp package.json $out/package.json
88+ '';
89+ };
90+
91+ # --- Container assembly -------------------------------------------------
92+ # Runs both processes the same way the Dockerfile's CMD did: the Go API
93+ # in the background on loopback:8080, the SvelteKit Node server in front
94+ # on $PORT, proxying /api to it.
95+ entrypoint = pkgs.writeShellScriptBin "glean-entrypoint" ''
96+ set -euo pipefail
97+ export GLEAN_ADDR="127.0.0.1:8080"
98+ export GLEAN_API_URL="http://127.0.0.1:8080"
99+ ${glean}/bin/glean &
100+ GO_PID=$!
101+ trap 'kill "$GO_PID" 2>/dev/null || true' INT TERM
102+ exec ${pkgs.nodejs_22}/bin/node ${frontend}/build/index.js
103+ '';
104+ in
105+ {
106+ packages.${system} = {
107+ inherit glean frontend webDeps;
108+
109+ image = pkgs.dockerTools.streamLayeredImage {
110+ name = "glean";
111+ tag = "latest";
112+ contents = [ pkgs.cacert pkgs.tzdata pkgs.dockerTools.fakeNss entrypoint ];
113+ config = {
114+ Cmd = [ "${entrypoint}/bin/glean-entrypoint" ];
115+ Env = [ "PORT=3000" ];
116+ ExposedPorts = { "3000/tcp" = { }; };
117+ };
118+ };
119+ };
120+ };
121+}
new file mode 100644
@@ -0,0 +1,121 @@
1+{
2+ description = "glean: Go API + SvelteKit frontend, packaged as a container image via dockerTools";
3+
4+ inputs = {
5+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+ };
7+
8+ outputs = { self, nixpkgs }:
9+ let
10+ system = "x86_64-linux";
11+ pkgs = import nixpkgs { inherit system; };
12+ lib = pkgs.lib;
13+
14+ # --- Go API binary -----------------------------------------------------
15+ # Mirrors the Dockerfile's CGO setup: mattn/go-sqlite3 vendors its own
16+ # sqlite3 amalgamation, but sqlite-vec-go-bindings' cgo code expects a
17+ # plain `sqlite3.h` on the include path. internal/db/include/sqlite3.h
18+ # is that header; go-sqlite3's own module dir is added too so the
19+ # u_intN_t compat defines line up with the same sqlite3 version.
20+ glean = pkgs.buildGoModule {
21+ pname = "glean";
22+ version = "0.0.1";
23+ src = ./.;
24+ vendorHash = "sha256-EYJD4hBs4RT9Qwccqw0G58Hdn7TtJKfSAL4CHQVLXO0=";
25+
26+ env.CGO_ENABLED = "1";
27+ tags = [ "fts5" ];
28+ ldflags = [ "-s" "-w" ];
29+
30+ # buildGoModule builds with `-mod=vendor` against a `vendor/` tree it
31+ # generates itself (that's what vendorHash actually pins), so the
32+ # go-sqlite3 header lives under vendor/, not $(go env GOMODCACHE).
33+ preBuild = ''
34+ export CGO_CFLAGS="-I$PWD/internal/db/include -I$PWD/vendor/github.com/mattn/go-sqlite3 -Du_int8_t=uint8_t -Du_int16_t=uint16_t -Du_int64_t=uint64_t"
35+ '';
36+
37+ doCheck = false;
38+ };
39+
40+ # --- SvelteKit frontend (adapter-node) ---------------------------------
41+ # bun install needs network access, which the nix sandbox forbids for a
42+ # normal derivation -- split into a fixed-output "fetch deps" step
43+ # (network allowed, output hash pinned) and a sandboxed "build" step
44+ # that only ever sees the already-fetched node_modules.
45+ webDeps = pkgs.stdenvNoCC.mkDerivation {
46+ pname = "glean-web-deps";
47+ version = "0.0.1";
48+ src = ./web;
49+ nativeBuildInputs = [ pkgs.bun pkgs.cacert ];
50+
51+ buildPhase = ''
52+ export HOME=$TMPDIR
53+ export SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
54+ bun install --frozen-lockfile
55+ '';
56+ installPhase = ''
57+ mkdir -p $out
58+ cp -r node_modules $out/node_modules
59+ '';
60+
61+ outputHashMode = "recursive";
62+ outputHashAlgo = "sha256";
63+ outputHash = "sha256-q/VJbH1rWCsxf3A3RYb22t2RrtjUm4xCCrCZkLkAFFY=";
64+ };
65+
66+ frontend = pkgs.stdenvNoCC.mkDerivation {
67+ pname = "glean-web";
68+ version = "0.0.1";
69+ src = ./web;
70+ # nodejs_22 is needed so patchShebangs below has a `node` binary on
71+ # PATH to point node_modules/.bin scripts' shebangs at.
72+ nativeBuildInputs = [ pkgs.bun pkgs.nodejs_22 ];
73+
74+ buildPhase = ''
75+ export HOME=$TMPDIR
76+ cp -r ${webDeps}/node_modules .
77+ chmod -R u+w node_modules
78+ # node_modules/.bin scripts have `#!/usr/bin/env node` shebangs;
79+ # /usr/bin/env doesn't exist inside the nix sandbox, so patch them
80+ # to point at the real node on the store path.
81+ patchShebangs node_modules
82+ bun run build
83+ '';
84+ installPhase = ''
85+ mkdir -p $out
86+ cp -r build $out/build
87+ cp package.json $out/package.json
88+ '';
89+ };
90+
91+ # --- Container assembly -------------------------------------------------
92+ # Runs both processes the same way the Dockerfile's CMD did: the Go API
93+ # in the background on loopback:8080, the SvelteKit Node server in front
94+ # on $PORT, proxying /api to it.
95+ entrypoint = pkgs.writeShellScriptBin "glean-entrypoint" ''
96+ set -euo pipefail
97+ export GLEAN_ADDR="127.0.0.1:8080"
98+ export GLEAN_API_URL="http://127.0.0.1:8080"
99+ ${glean}/bin/glean &
100+ GO_PID=$!
101+ trap 'kill "$GO_PID" 2>/dev/null || true' INT TERM
102+ exec ${pkgs.nodejs_22}/bin/node ${frontend}/build/index.js
103+ '';
104+ in
105+ {
106+ packages.${system} = {
107+ inherit glean frontend webDeps;
108+
109+ image = pkgs.dockerTools.streamLayeredImage {
110+ name = "glean";
111+ tag = "latest";
112+ contents = [ pkgs.cacert pkgs.tzdata pkgs.dockerTools.fakeNss entrypoint ];
113+ config = {
114+ Cmd = [ "${entrypoint}/bin/glean-entrypoint" ];
115+ Env = [ "PORT=3000" ];
116+ ExposedPorts = { "3000/tcp" = { }; };
117+ };
118+ };
119+ };
120+ };
121+}
added scripts/build-image.sh +39 -0
new file mode 100755
@@ -0,0 +1,39 @@
1+#!/bin/bash
2+# Builds the glean container image with Nix (pkgs.dockerTools.streamLayeredImage,
3+# defined in flake.nix) on a remote builder over SSH -- this dev machine has no
4+# `nix` installed, so the actual build can't happen locally. Side-effecting (rsync
5+# + ssh) on purpose: buck2's genrule for :image just calls this script and stays
6+# pure/uninvolved in how the remote build actually happens.
7+#
8+# Usage: scripts/build-image.sh <srcdir> <output-tar-path>
9+set -euo pipefail
10+# $SRCDIR is populated by the genrule's `srcs = glob(...)` as a symlink farm
11+# mirroring the repo tree -- NOT this script's own location (which, after
12+# export_file, is a buck-out copy) and NOT $PWD (buck2 runs genrule cmds with
13+# cwd at a srcs scratch dir, not the project root).
14+DIR="$1"
15+OUT="$2"
16+
17+NIX_VM="${GLEAN_NIX_VM:-nix-vm}"
18+REMOTE_DIR="${GLEAN_NIX_VM_DIR:-~/builds/glean}"
19+
20+echo "==> syncing source to $NIX_VM:$REMOTE_DIR" >&2
21+ssh "$NIX_VM" "mkdir -p $REMOTE_DIR"
22+# -L dereferences $SRCDIR's symlinks (they point back at buck2's srcs farm,
23+# which doesn't exist on the remote host) so real file content gets copied.
24+rsync -aL --delete \
25+ --exclude .git \
26+ --exclude buck-out \
27+ --exclude web/node_modules \
28+ --exclude web/.svelte-kit \
29+ --exclude web/build \
30+ -e ssh \
31+ "$DIR/" "$NIX_VM:$REMOTE_DIR/"
32+
33+echo "==> building .#image on $NIX_VM" >&2
34+STORE_PATH="$(ssh "$NIX_VM" "cd $REMOTE_DIR && nix build .#image --print-out-paths --no-link -L")"
35+
36+echo "==> streaming image (docker-archive tar) back from $NIX_VM" >&2
37+ssh "$NIX_VM" "$STORE_PATH" > "$OUT"
38+
39+echo "==> wrote $OUT" >&2
new file mode 100755
@@ -0,0 +1,39 @@
1+#!/bin/bash
2+# Builds the glean container image with Nix (pkgs.dockerTools.streamLayeredImage,
3+# defined in flake.nix) on a remote builder over SSH -- this dev machine has no
4+# `nix` installed, so the actual build can't happen locally. Side-effecting (rsync
5+# + ssh) on purpose: buck2's genrule for :image just calls this script and stays
6+# pure/uninvolved in how the remote build actually happens.
7+#
8+# Usage: scripts/build-image.sh <srcdir> <output-tar-path>
9+set -euo pipefail
10+# $SRCDIR is populated by the genrule's `srcs = glob(...)` as a symlink farm
11+# mirroring the repo tree -- NOT this script's own location (which, after
12+# export_file, is a buck-out copy) and NOT $PWD (buck2 runs genrule cmds with
13+# cwd at a srcs scratch dir, not the project root).
14+DIR="$1"
15+OUT="$2"
16+
17+NIX_VM="${GLEAN_NIX_VM:-nix-vm}"
18+REMOTE_DIR="${GLEAN_NIX_VM_DIR:-~/builds/glean}"
19+
20+echo "==> syncing source to $NIX_VM:$REMOTE_DIR" >&2
21+ssh "$NIX_VM" "mkdir -p $REMOTE_DIR"
22+# -L dereferences $SRCDIR's symlinks (they point back at buck2's srcs farm,
23+# which doesn't exist on the remote host) so real file content gets copied.
24+rsync -aL --delete \
25+ --exclude .git \
26+ --exclude buck-out \
27+ --exclude web/node_modules \
28+ --exclude web/.svelte-kit \
29+ --exclude web/build \
30+ -e ssh \
31+ "$DIR/" "$NIX_VM:$REMOTE_DIR/"
32+
33+echo "==> building .#image on $NIX_VM" >&2
34+STORE_PATH="$(ssh "$NIX_VM" "cd $REMOTE_DIR && nix build .#image --print-out-paths --no-link -L")"
35+
36+echo "==> streaming image (docker-archive tar) back from $NIX_VM" >&2
37+ssh "$NIX_VM" "$STORE_PATH" > "$OUT"
38+
39+echo "==> wrote $OUT" >&2
added toolchains/BUCK +5 -0
new file mode 100644
@@ -0,0 +1,5 @@
1+load("@prelude//toolchains:demo.bzl", "system_demo_toolchains")
2+
3+# All the default toolchains, suitable for a quick demo or early prototyping.
4+# Most real projects should copy/paste the implementation to configure them.
5+system_demo_toolchains()
new file mode 100644
@@ -0,0 +1,5 @@
1+load("@prelude//toolchains:demo.bzl", "system_demo_toolchains")
2+
3+# All the default toolchains, suitable for a quick demo or early prototyping.
4+# Most real projects should copy/paste the implementation to configure them.
5+system_demo_toolchains()