1{ inputs, ... }:
2{
3 perSystem =
4 { pkgs, ... }:
5 let
6 # NOTE: Duplicated because this is in a separate flake-parts partition
7 # than ./packages.nix
8 mkZed = import ../toolchain.nix { inherit inputs; };
9 zed-editor = mkZed pkgs;
10
11 rustBin = inputs.rust-overlay.lib.mkRustBin { } pkgs;
12 rustToolchain = rustBin.fromRustupToolchainFile ../../rust-toolchain.toml;
13
14 baseEnv =
15 (zed-editor.overrideAttrs (attrs: {
16 passthru.env = attrs.env;
17 })).env; # exfil `env`; it's not in drvAttrs
18
19 # Musl cross-compiler for building remote_server
20 muslCross = pkgs.pkgsCross.musl64;
21
22 # Cargo build timings wrapper script
23 wrappedCargo = pkgs.writeShellApplication {
24 name = "cargo";
25 runtimeInputs = [pkgs.nodejs];
26 text = ''
27 NIX_WRAPPER=1 CARGO=${rustToolchain}/bin/cargo ./script/cargo "$@"
28 '';
29 };
30 in
31 {
32 devShells.default = (pkgs.mkShell.override { inherit (zed-editor) stdenv; }) {
33 name = "zed-editor-dev";
34 inputsFrom = [ zed-editor ];
35
36 packages = with pkgs; [
37 wrappedCargo # must be first, to shadow the `cargo` provided by `rustToolchain`
38 rustToolchain # cargo, rustc, and rust-toolchain.toml components included
39 cargo-nextest
40 cargo-hakari
41 cargo-machete
42 cargo-zigbuild
43 # TODO: package protobuf-language-server for editing zed.proto
44 # TODO: add other tools used in our scripts
45
46 # `build.nix` adds this to the `zed-editor` wrapper (see `postFixup`)
47 # we'll just put it on `$PATH`:
48 nodejs_22
49 zig
50 ];
51
52 env =
53 (removeAttrs baseEnv [
54 "LK_CUSTOM_WEBRTC" # download the staticlib during the build as usual
55 "ZED_UPDATE_EXPLANATION" # allow auto-updates
56 "CARGO_PROFILE" # let you specify the profile
57 "TARGET_DIR"
58 ])
59 // {
60 # note: different than `$FONTCONFIG_FILE` in `build.nix` – this refers to relative paths
61 # outside the nix store instead of to `$src`
62 FONTCONFIG_FILE = pkgs.makeFontsConf {
63 fontDirectories = [
64 "./assets/fonts/lilex"
65 "./assets/fonts/ibm-plex-sans"
66 ];
67 };
68 PROTOC = "${pkgs.protobuf}/bin/protoc";
69 ZED_ZSTD_MUSL_LIB = "${pkgs.pkgsCross.musl64.pkgsStatic.zstd.out}/lib";
70 # For aws-lc-sys musl cross-compilation
71 CC_x86_64_unknown_linux_musl = "${muslCross.stdenv.cc}/bin/x86_64-unknown-linux-musl-gcc";
72 };
73 };
74 };
75}