Repository navigation
Expand file tree
/
Copy pathdevenv.nix
More file actions
188 lines (179 loc) · 7.98 KB
/
Copy pathdevenv.nix
File metadata and controls
188 lines (179 loc) · 7.98 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# Keyflow's dev environment. devenv-fleet's `rust` module (devenv.yaml) gives
# the toolchain, hakari, cargo-rail, mold, prek and kache's wrapper; its
# `dioxus` module gives dx and the wasm C toolchain. This file adds what the
# native and wasm builds link against and run, the Playwright browsers, and
# the nightly door the worklet build needs.
{ pkgs, lib, inputs, ... }:
let
# Playwright's browsers come from the nixpkgs-dx pin: its playwright-driver
# (1.59.1) matches the @playwright/test pin in tests/package.json. Without
# it Playwright falls back to a downloaded chromium that cannot load its
# shared libs on NixOS (libnspr4.so).
pkgsDx = import inputs.nixpkgs-dx { inherit (pkgs.stdenv) system; };
# `cargo-nightly`: the one door to a nightly with rust-src and the wasm
# target, for the browser keys worklet's shared-memory build (wasm threads
# need `-Z build-std`). Reached by name only; the 1.99.1 pin stays on PATH.
rustNightly = pkgs.rust-bin.selectLatestNightlyWith (t: t.minimal);
rustNightlyWasm = pkgs.rust-bin.selectLatestNightlyWith (t:
t.minimal.override {
extensions = [ "rust-src" ];
targets = [ "wasm32-unknown-unknown" ];
});
cargoNightly = pkgs.writeShellScriptBin "cargo-nightly" ''
export RUSTC="${rustNightlyWasm}/bin/rustc"
exec ${rustNightlyWasm}/bin/cargo "$@"
'';
# The libraries the linker finds, also on the loader path so a desktop test
# binary runs from this shell. The C++ runtime too: Luau is C++.
libPath = lib.makeLibraryPath ([ pkgs.stdenv.cc.cc.lib pkgs.fontconfig pkgs.freetype pkgs.openssl ]
++ lib.optionals pkgs.stdenv.isLinux (with pkgs; [
alsa-lib libjack2 pipewire
libGL vulkan-loader gtk3 glib
gdk-pixbuf pango cairo atk
libx11 libxcb libxkbcommon wayland
webkitgtk_4_1 libsoup_3 xdotool
]));
in
{
packages = with pkgs; [
cargo-watch
cargo-nextest
bacon
flac
# uv — the graphify bootstrap in enterShell (graphify is a PyPI tool).
uv
cargoNightly
# Native headers and build tools for the cargo builds.
openssl
openssl.dev
libiconv
fontconfig
freetype
cmake
python3
# bindgen's clang paths; git — cargo shells out to it for every git dep.
rustPlatform.bindgenHook
git
]
++ lib.optionals pkgs.stdenv.isLinux (with pkgs; [
alsa-lib alsa-lib.dev
# libudev — hidapi's build script pkg-configs it (kontrol's raw USB HID).
udev
# ONNX Runtime for Chatterbox TTS (session-guide/tts): `ort` dlopens it.
onnxruntime
# JACK headers for cpal's `jack` feature (signal-sampler).
libjack2
# libpipewire headers for cpal's native `pipewire` feature.
pipewire pipewire.dev
glib gtk3 gdk-pixbuf pango cairo atk harfbuzz
libsoup_3 webkitgtk_4_1 xdotool
libx11 libxcursor libxrandr libxi libxcb
libxkbcommon wayland libGL vulkan-loader
# pw-jack runs the live rigs through PipeWire's JACK shim; jack_iodelay
# and jack_lsp measure real round-trip latency.
pipewire.jack
jack-example-tools
# Xvfb + xvfb-run — virtual display for the REAPER integration-test
# harness (`just reaper-integration-test`).
xorg.xorgserver
xvfb-run
# cargo-sweep — reclaims stale target/ artifacts (`just sweep`).
cargo-sweep
]);
env = {
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
OPENSSL_DIR = "${pkgs.openssl.dev}";
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
PLAYWRIGHT_BROWSERS_PATH = "${pkgsDx.playwright-driver.browsers}";
PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS = "true";
}
// lib.optionalAttrs pkgs.stdenv.isLinux {
LD_LIBRARY_PATH = libPath;
# `ort` (load-dynamic) dlopens this exact .so. Unset, synthesis fails and
# section cues fall back to the synth chime; the app still runs.
ORT_DYLIB_PATH = "${pkgs.onnxruntime}/lib/libonnxruntime.so";
XDG_DATA_DIRS = "${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}";
# WebKitGTK's accelerated compositing fails on NixOS (GBM buffer error,
# white window). https://github.com/NixOS/nixpkgs/issues/32580
WEBKIT_DISABLE_COMPOSITING_MODE = "1";
}
// lib.optionalAttrs pkgs.stdenv.isDarwin (
let
# ring's wasm build uses clang-18, but DYLD_LIBRARY_PATH makes it load the
# stdenv's clang-21 libclang-cpp (SIGABRT). Run it with that unset.
wasmCC = pkgs.writeShellScript "wasm-clang-18" ''
exec /usr/bin/env -u DYLD_LIBRARY_PATH ${pkgs.llvmPackages_18.clang-unwrapped}/bin/clang "$@"
'';
in
{
DYLD_LIBRARY_PATH = libPath;
CC_wasm32_unknown_unknown = "${wasmCC}";
# phon-jit's build script compiles its `become` stencils with this nightly.
PHON_JIT_NIGHTLY_RUSTC = "${rustNightly}/bin/rustc";
}
);
enterShell = ''
# Appended, not prepended: store-provided tools must win over stale
# cargo-installed copies; cargo and uv bins only need to be reachable.
export PATH="$PATH:$HOME/.cargo/bin:$HOME/.local/bin"
# Dev-convenience installers are for an interactive shell only. In CI, or
# under direnv, `cargo install tracey` would compile from source each time.
if [ -t 1 ] && [ -z "''${CI:-}" ]; then
# graphify — whole-repo knowledge graph (safishamsi/graphify), pinned.
# Code extraction is local (tree-sitter); the [mcp] extra serves it.
GRAPHIFY_VERSION="0.9.15"
if ! uv tool list 2>/dev/null | grep -q "graphifyy v$GRAPHIFY_VERSION"; then
echo " Installing graphify $GRAPHIFY_VERSION..."
UV_PYTHON_DOWNLOADS=never uv tool install --force \
--python "${pkgs.python3}/bin/python3" \
"graphifyy[mcp]==$GRAPHIFY_VERSION" >/dev/null 2>&1 || \
echo " (graphify install failed — run: uv tool install 'graphifyy[mcp]==$GRAPHIFY_VERSION')"
fi
# tracey — spec-coverage CLI (crates.io), pinned. Config: .config/tracey/config.styx.
TRACEY_VERSION=$(tracey --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || echo "0")
if [ "$TRACEY_VERSION" != "1.3.0" ]; then
echo " Installing tracey 1.3.0..."
cargo install tracey --locked --version "=1.3.0" 2>/dev/null || true
fi
fi
'';
# dx on the app's own Dioxus line (0.8.0-alpha.3, DioxusLabs/dioxus
# 430cfb56, the revision Architect pins), with the fleet's
# DX_NO_RUSTC_WRAPPER patch. The fleet's dx (pins.json, 0.8.0-alpha.0)
# is a protocol behind: `dx serve --hot-patch` refuses the app as
# incompatible, and a save restarts the window instead of patching it.
# `fleet.dioxus.package` is the module's per-repo door while moving
# between dx revisions; this moves to devenv-fleet's pins.json.
fleet.dioxus.package =
let
pkgsDx = import inputs.nixpkgs-dx { inherit (pkgs.stdenv) system; };
in
pkgsDx.dioxus-cli.overrideAttrs (old: rec {
version = "0.8.0-alpha.3";
src = pkgsDx.fetchFromGitHub {
owner = "DioxusLabs";
repo = "dioxus";
rev = "430cfb563f1b70602ef387f0c80f171d84527b41";
hash = "sha256-ZWqLFm5apsJu24ishMsilTkndLrlRmb0JQRyVXSBt50=";
};
cargoDeps = pkgsDx.rustPlatform.fetchCargoVendor {
inherit src;
name = "dioxus-cli-${version}-vendor";
hash = "sha256-ITAru/fdxXM03irEstnahGFK+eJwEgrlmQzYBshDajQ=";
};
buildAndTestSubdir = "packages/cli";
patches = [ "${inputs.devenv-fleet}/pkgs/dx-no-rustc-wrapper.patch" ];
doCheck = false;
doInstallCheck = false;
});
# `devenv up`: Keyflow's development window beside the telemetry stack.
# apps/architect is the Architect app with the Keyflow extension compiled
# in, in a config folder of its own (keyflow-dev), its vault seeded from
# apps/architect/vault. `just app` is the same without the stack.
processes.keyflow.exec = "just app";
fleet.banner = ''
Keyflow: devenv up (or just app) opens the editor window
just check / just test / just ci, just kf --help (the keyflow CLI)
just graph (re)builds the repo knowledge graph
'';
}