Skip to content

Commit 6f81f39

Browse files
authored
Merge pull request #465 from spacedriveapp/fix/imap-proto-vendor
Fix imap-proto build issues and update Nix dependencies
2 parents 2876d5a + b703381 commit 6f81f39

5 files changed

Lines changed: 233 additions & 149 deletions

File tree

AGENTS.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,32 @@ Additional rules:
4343
- For changes in async/stateful paths (worker lifecycle, cancellation, retrigger, recall cache behavior), include explicit race/terminal-state reasoning in the PR summary and run targeted tests in addition to `just gate-pr`.
4444
- Do not push if any gate is red.
4545

46+
## Nix Flake Workflow
47+
48+
### Frontend Dependencies
49+
50+
When updating frontend dependencies in `interface/`:
51+
52+
1. **Update deps:** Modify `interface/package.json` or `interface/bun.lock` as needed
53+
2. **Update the Nix hash:** Run `just update-frontend-hash`
54+
- This builds the `frontend-updater` package with `fakeHash`
55+
- Extracts the new hash from the build output
56+
- Updates `nix/default.nix` automatically
57+
3. **Verify:** Run `nix build .#frontend` to confirm the build works
58+
4. **Commit:** Include both the dependency changes and the hash update in the same PR
59+
60+
**Note:** The `just update-frontend-hash` command uses the `fakeHash` pattern (standard Nix practice) where the build intentionally fails to reveal the correct hash, which is then extracted and applied automatically.
61+
62+
### Nix Flake Inputs
63+
64+
To update all Nix flake inputs (nixpkgs, crane, etc.) and regenerate `flake.lock`:
65+
66+
```bash
67+
just update-flake
68+
```
69+
70+
This runs `nix flake update` and updates all inputs to their latest versions.
71+
4672
## Architecture Overview
4773

4874
Five process types. Every LLM process is a Rig `Agent<SpacebotModel, SpacebotHook>`. They differ in system prompt, tools, history, and hooks.

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@
3535
./src
3636
./migrations
3737
./prompts
38+
./presets
39+
./docs/content
40+
./docs/README.md
41+
./docs/docker.md
42+
./docs/metrics.md
43+
./AGENTS.md
44+
./README.md
45+
./CHANGELOG.md
46+
./.cargo/config.toml
47+
(pkgs.lib.fileset.maybeMissing ./interface/dist)
48+
./vendor
3849
];
3950
};
4051

@@ -66,11 +77,14 @@
6677
inherit pkgs craneLib cargoSrc runtimeAssetsSrc frontendSrc;
6778
};
6879

69-
inherit (spacebotPackages) frontend spacebot spacebot-full spacebot-tests;
80+
inherit (spacebotPackages) frontend frontendNodeModules spacebot spacebot-full spacebot-tests;
7081
in {
7182
packages = {
7283
default = spacebot;
7384
inherit frontend spacebot spacebot-full;
85+
# Updater for frontend deps - run this to get the correct hash after updating interface deps
86+
# Usage: nix build .#frontend-updater 2>&1 | grep "got:" | awk '{print $2}'
87+
frontend-updater = frontendNodeModules { hash = pkgs.lib.fakeHash; };
7488
};
7589

7690
devShells = {
@@ -88,11 +102,10 @@
88102
openssl
89103
pkg-config
90104
onnxruntime
91-
chromium
92-
];
105+
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [ pkgs.chromium ];
93106

94107
ORT_LIB_LOCATION = "${pkgs.onnxruntime}/lib";
95-
CHROME_PATH = "${pkgs.chromium}/bin/chromium";
108+
CHROME_PATH = if pkgs.stdenv.isLinux then "${pkgs.chromium}/bin/chromium" else "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
96109
CHROME_FLAGS = "--no-sandbox --disable-dev-shm-usage --disable-gpu";
97110
};
98111

justfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,44 @@ desktop-dev:
5353
# Tauri's beforeBuildCommand handles sidecar bundling and frontend build automatically.
5454
desktop-build:
5555
cd desktop && bun run tauri:build
56+
57+
# Update the frontend node_modules hash in nix/default.nix after updating interface dependencies.
58+
# Usage: Update interface/package.json or interface/bun.lock, then run: just update-frontend-hash
59+
update-frontend-hash:
60+
#!/usr/bin/env bash
61+
set -euo pipefail
62+
echo "Building frontend-updater to get new hash..."
63+
output=$(nix build .#frontend-updater 2>&1 || true)
64+
new_hash=$(echo "$output" | awk '/got:/ {print $2}' || true)
65+
66+
if [ -z "$new_hash" ]; then
67+
echo "Error: Failed to extract hash from build output"
68+
echo "Build output:"
69+
echo "$output"
70+
exit 1
71+
fi
72+
73+
echo "New hash: $new_hash"
74+
75+
# Check if hash is already up to date
76+
current_hash=$(grep -E 'hash \?' nix/default.nix | head -1 | sed -E 's/.*hash \? "([^"]+)".*/\1/')
77+
if [ "$current_hash" = "$new_hash" ]; then
78+
echo "Hash is already up to date!"
79+
exit 0
80+
fi
81+
82+
# Update the hash in nix/default.nix (POSIX-safe in-place edit)
83+
tmpfile=$(mktemp)
84+
sed -E "s|hash \? \"[^\"]+\"|hash ? \"$new_hash\"|" nix/default.nix > "$tmpfile"
85+
mv "$tmpfile" nix/default.nix
86+
echo "Updated nix/default.nix with new hash"
87+
echo ""
88+
echo "Next steps:"
89+
echo " 1. Review the changes: git diff nix/default.nix"
90+
echo " 2. Test the build: nix build .#frontend"
91+
echo " 3. Commit the changes: git add nix/default.nix && git commit -m 'update: frontend node_modules hash'"
92+
93+
# Update all Nix flake inputs (flake.lock).
94+
# Use this when you want to update dependencies like nixpkgs, crane, etc.
95+
update-flake:
96+
nix flake update --extra-experimental-features "nix-command flakes"

0 commit comments

Comments
 (0)