shell.nix

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