1{
2 mkShell,
3 makeFontsConf,
4 lib,
5
6 zed-editor,
7
8 rust-analyzer,
9 cargo-nextest,
10 cargo-hakari,
11 cargo-machete,
12 nixfmt-rfc-style,
13 protobuf,
14 nodejs_22,
15 cowsay,
16}:
17(mkShell.override { inherit (zed-editor) stdenv; }) {
18 inputsFrom = [ zed-editor ];
19 packages = [
20 rust-analyzer
21 cargo-nextest
22 cargo-hakari
23 cargo-machete
24 nixfmt-rfc-style
25 # TODO: package protobuf-language-server for editing zed.proto
26 # TODO: add other tools used in our scripts
27
28 # `build.nix` adds this to the `zed-editor` wrapper (see `postFixup`)
29 # we'll just put it on `$PATH`:
30 nodejs_22
31 ];
32
33 env =
34 let
35 baseEnvs =
36 (zed-editor.overrideAttrs (attrs: {
37 passthru = { inherit (attrs) env; };
38 })).env; # exfil `env`; it's not in drvAttrs
39 in
40 (removeAttrs baseEnvs [
41 "LK_CUSTOM_WEBRTC" # download the staticlib during the build as usual
42 "ZED_UPDATE_EXPLANATION" # allow auto-updates
43 "CARGO_PROFILE" # let you specify the profile
44 "TARGET_DIR"
45 ])
46 // {
47 # note: different than `$FONTCONFIG_FILE` in `build.nix` – this refers to relative paths
48 # outside the nix store instead of to `$src`
49 FONTCONFIG_FILE = makeFontsConf {
50 fontDirectories = [
51 "./assets/fonts/lilex"
52 "./assets/fonts/ibm-plex-sans"
53 ];
54 };
55 PROTOC = "${protobuf}/bin/protoc";
56 };
57
58 shellHook = lib.optionalString zed-editor.stdenv.hostPlatform.isDarwin ''
59 set -x
60 metal_compiler="$(env -u SDKROOT /usr/bin/xcrun -f metal)"
61 if ! $("$metal_compiler" --help &> /dev/null); then
62 {
63 echo 'Leave the devshell and run `xcodebuild -downloadComponent MetalToolchain`'
64 echo "to download the (proprietary 😤) metal compiler, or you'll need to pass"
65 echo '`--features gpui/runtime_shaders` to cargo.'
66 } |
67 ${lib.getExe cowsay} -W 80
68 else
69 XCRUN_PATH=/usr/bin/xcrun
70 fi;
71 '';
72}