shell.nix

 1{
 2  mkShell,
 3  stdenv,
 4  stdenvAdapters,
 5  makeFontsConf,
 6
 7  zed-editor,
 8
 9  rust-analyzer,
10  cargo-nextest,
11  nixfmt-rfc-style,
12  protobuf,
13  nodejs_22,
14}:
15let
16  moldStdenv = stdenvAdapters.useMoldLinker stdenv;
17  mkShell' =
18    if stdenv.hostPlatform.isLinux then mkShell.override { stdenv = moldStdenv; } else mkShell;
19in
20mkShell' {
21  inputsFrom = [ zed-editor ];
22  packages = [
23    rust-analyzer
24    cargo-nextest
25    nixfmt-rfc-style
26    # TODO: package protobuf-language-server for editing zed.proto
27    # TODO: add other tools used in our scripts
28
29    # `build.nix` adds this to the `zed-editor` wrapper (see `postFixup`)
30    # we'll just put it on `$PATH`:
31    nodejs_22
32  ];
33
34  env =
35    let
36      baseEnvs =
37        (zed-editor.overrideAttrs (attrs: {
38          passthru = { inherit (attrs) env; };
39        })).env; # exfil `env`; it's not in drvAttrs
40    in
41    (removeAttrs baseEnvs [
42      "LK_CUSTOM_WEBRTC" # download the staticlib during the build as usual
43      "ZED_UPDATE_EXPLANATION" # allow auto-updates
44      "CARGO_PROFILE" # let you specify the profile
45      "TARGET_DIR"
46    ])
47    // {
48      # note: different than `$FONTCONFIG_FILE` in `build.nix` – this refers to relative paths
49      # outside the nix store instead of to `$src`
50      FONTCONFIG_FILE = makeFontsConf {
51        fontDirectories = [
52          "./assets/fonts/plex-mono"
53          "./assets/fonts/plex-sans"
54        ];
55      };
56      PROTOC = "${protobuf}/bin/protoc";
57    };
58}