flake.nix

 1{
 2  description = "High-performance, multiplayer code editor from the creators of Atom and Tree-sitter";
 3
 4  inputs = {
 5    nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
 6    rust-overlay = {
 7      url = "github:oxalica/rust-overlay";
 8      inputs.nixpkgs.follows = "nixpkgs";
 9    };
10    flake-compat.url = "github:edolstra/flake-compat";
11  };
12
13  outputs =
14    { nixpkgs, rust-overlay, ... }:
15    let
16      systems = [
17        "x86_64-linux"
18        "x86_64-darwin"
19        "aarch64-linux"
20        "aarch64-darwin"
21      ];
22
23      overlays = {
24        rust-overlay = rust-overlay.overlays.default;
25        rust-toolchain = final: prev: {
26          rustToolchain = final.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
27        };
28        zed-editor = final: prev: {
29          zed-editor = final.callPackage ./nix/build.nix {
30            rustPlatform = final.makeRustPlatform {
31              cargo = final.rustToolchain;
32              rustc = final.rustToolchain;
33            };
34          };
35        };
36      };
37
38      mkPkgs =
39        system:
40        import nixpkgs {
41          inherit system;
42          overlays = builtins.attrValues overlays;
43        };
44
45      forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f (mkPkgs system));
46    in
47    {
48      packages = forAllSystems (pkgs: {
49        zed-editor = pkgs.zed-editor;
50        default = pkgs.zed-editor;
51      });
52
53      devShells = forAllSystems (pkgs: {
54        default = import ./nix/shell.nix { inherit pkgs; };
55      });
56
57      formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
58
59      overlays = overlays // {
60        default = nixpkgs.lib.composeManyExtensions (builtins.attrValues overlays);
61      };
62    };
63}