flake.nix

 1{
 2  description = "High-performance, multiplayer code editor from the creators of Atom and Tree-sitter";
 3
 4  inputs = {
 5    nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz";
 6    rust-overlay = {
 7      url = "github:oxalica/rust-overlay";
 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    {
16      nixpkgs,
17      rust-overlay,
18      crane,
19      ...
20    } @ inputs:
21    let
22      systems = [
23        "x86_64-linux"
24        "x86_64-darwin"
25        "aarch64-linux"
26        "aarch64-darwin"
27      ];
28
29      forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
30      mkZed =
31        pkgs:
32        let
33          rustBin = rust-overlay.lib.mkRustBin { } pkgs;
34        in
35        pkgs.callPackage ./nix/build.nix {
36          crane = crane.mkLib pkgs;
37          rustToolchain = rustBin.fromRustupToolchainFile ./rust-toolchain.toml;
38        };
39    in
40    {
41      packages = forAllSystems (pkgs: rec {
42        default = mkZed pkgs;
43        debug = default.override { profile = "dev"; };
44      });
45      devShells = forAllSystems (pkgs: {
46        default = pkgs.callPackage ./nix/shell.nix {
47          zed-editor = mkZed pkgs;
48        };
49      });
50      formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
51      overlays.default = final: _: {
52        zed-editor = mkZed final;
53      };
54      checks = forAllSystems (pkgs: {
55        simple = (import ./nix/test/simple.nix) {
56          inherit pkgs; 
57          zed = mkZed pkgs;
58        };
59      });
60    };
61
62  nixConfig = {
63    extra-substituters = [
64      "https://zed.cachix.org"
65      "https://cache.garnix.io"
66    ];
67    extra-trusted-public-keys = [
68      "zed.cachix.org-1:/pHQ6dpMsAZk2DiP4WCL0p9YDNKWj2Q5FL20bNmw1cU="
69      "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
70    ];
71  };
72}