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 let
28 pathToCargoScript = ./. + "/../../script/cargo";
29 in
30 ''
31 NIX_WRAPPER=1 CARGO=${rustToolchain}/bin/cargo ${pathToCargoScript} "$@"
32 '';
33 };
34 in
35 {
36 devShells.default = (pkgs.mkShell.override { inherit (zed-editor) stdenv; }) {
37 name = "zed-editor-dev";
38 inputsFrom = [ zed-editor ];
39
40 packages = with pkgs; [
41 wrappedCargo # must be first, to shadow the `cargo` provided by `rustToolchain`
42 rustToolchain # cargo, rustc, and rust-toolchain.toml components included
43 cargo-nextest
44 cargo-hakari
45 cargo-machete
46 cargo-zigbuild
47 # TODO: package protobuf-language-server for editing zed.proto
48 # TODO: add other tools used in our scripts
49
50 # `build.nix` adds this to the `zed-editor` wrapper (see `postFixup`)
51 # we'll just put it on `$PATH`:
52 nodejs_22
53 zig
54
55 # A11y testing script `script/a11y-inspector`
56 gobject-introspection # shell hook that populates GI_TYPELIB_PATH
57 at-spi2-core # provides Atspi-2.0.typelib and DBus-1.0.typelib
58 (python3.withPackages (ps: [ps.pyatspi ps.pygobject3]))
59 accerciser
60 ];
61
62 env =
63 (removeAttrs baseEnv [
64 "LK_CUSTOM_WEBRTC" # download the staticlib during the build as usual
65 "ZED_UPDATE_EXPLANATION" # allow auto-updates
66 "CARGO_PROFILE" # let you specify the profile
67 "TARGET_DIR"
68 ])
69 // {
70 # note: different than `$FONTCONFIG_FILE` in `build.nix` – this refers to relative paths
71 # outside the nix store instead of to `$src`
72 FONTCONFIG_FILE = pkgs.makeFontsConf {
73 fontDirectories = [
74 "./assets/fonts/lilex"
75 "./assets/fonts/ibm-plex-sans"
76 ];
77 };
78 PROTOC = "${pkgs.protobuf}/bin/protoc";
79 ZED_ZSTD_MUSL_LIB = "${pkgs.pkgsCross.musl64.pkgsStatic.zstd.out}/lib";
80 # For aws-lc-sys musl cross-compilation
81 CC_x86_64_unknown_linux_musl = "${muslCross.stdenv.cc}/bin/x86_64-unknown-linux-musl-gcc";
82 };
83 };
84 };
85}