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    forAllSystems = function:
21      nixpkgs.lib.genAttrs [
22        "x86_64-linux"
23        "aarch64-linux"
24      ] (system:
25        function (import nixpkgs {
26          inherit system;
27          overlays = [fenix.overlays.default];
28        }));
29  in {
30    packages = forAllSystems (pkgs: let
31      craneLib = (crane.mkLib pkgs).overrideToolchain (p: p.fenix.stable.toolchain);
32      rustPlatform = pkgs.makeRustPlatform {
33        inherit (pkgs.fenix.stable.toolchain) cargo rustc;
34      };
35      nightlyBuild = pkgs.callPackage ./nix/build.nix {
36        inherit craneLib rustPlatform;
37      };
38    in {
39      zed-editor = nightlyBuild;
40      default = nightlyBuild;
41    });
42
43    devShells = forAllSystems (pkgs: {
44      default = import ./nix/shell.nix {inherit pkgs;};
45    });
46
47    formatter = forAllSystems (pkgs: pkgs.alejandra);
48
49    overlays.default = final: prev: {
50      zed-editor = final.callPackage ./nix/build.nix {
51        craneLib = (crane.mkLib final).overrideToolchain (p: p.fenix.stable.toolchain);
52        rustPlatform = final.makeRustPlatform {
53          inherit (final.fenix.stable.toolchain) cargo rustc;
54        };
55      };
56    };
57  };
58}