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    fenix = {
 7      url = "github:nix-community/fenix";
 8      inputs.nixpkgs.follows = "nixpkgs";
 9    };
10    crane.url = "github:ipetkov/crane";
11    flake-compat.url = "github:edolstra/flake-compat";
12  };
13
14  outputs = {
15    nixpkgs,
16    crane,
17    fenix,
18    ...
19  }: let
20    systems = ["x86_64-linux" "aarch64-linux"];
21
22    overlays = {
23      fenix = fenix.overlays.default;
24      rust-toolchain = final: prev: {
25        rustToolchain = final.fenix.stable.toolchain;
26      };
27      zed-editor = final: prev: {
28        zed-editor = final.callPackage ./nix/build.nix {
29          craneLib = (crane.mkLib final).overrideToolchain final.rustToolchain;
30          rustPlatform = final.makeRustPlatform {
31            inherit (final.rustToolchain) cargo rustc;
32          };
33        };
34      };
35    };
36
37    mkPkgs = system:
38      import nixpkgs {
39        inherit system;
40        overlays = builtins.attrValues overlays;
41      };
42
43    forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f (mkPkgs system));
44  in {
45    packages = forAllSystems (pkgs: {
46      zed-editor = pkgs.zed-editor;
47      default = pkgs.zed-editor;
48    });
49
50    devShells = forAllSystems (pkgs: {
51      default = import ./nix/shell.nix {inherit pkgs;};
52    });
53
54    formatter = forAllSystems (pkgs: pkgs.alejandra);
55
56    overlays =
57      overlays
58      // {
59        default = nixpkgs.lib.composeManyExtensions (builtins.attrValues overlays);
60      };
61  };
62}