zed/flake.nix
Stanislav Alekseev 4564da2875
Improve Nix package and shell (#21075)
With an addition of useFetchCargoVendor, crane becomes less necessary
for our use. This reuses the package from nixpkgs as well as creating a
better devshell that both work on macOS.

I use Xcode's SDKROOT and DEVELOPER_DIR to point the swift in the
livekit client crate to a correct sdk when using a devshell. Devshell
should work without that once apple releases sources for the 15.1 SDK
but for now this is an easy fix

This also replaces fenix with rust-overlay because of issues with the
out-of-sandbox access I've noticed fenix installed toolchains have

Release Notes:

- N/A
2024-11-27 20:22:17 +02:00

63 lines
1.7 KiB
Nix

{
description = "High-performance, multiplayer code editor from the creators of Atom and Tree-sitter";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-compat.url = "github:edolstra/flake-compat";
};
outputs =
{ nixpkgs, rust-overlay, ... }:
let
systems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
overlays = {
rust-overlay = rust-overlay.overlays.default;
rust-toolchain = final: prev: {
rustToolchain = final.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
};
zed-editor = final: prev: {
zed-editor = final.callPackage ./nix/build.nix {
rustPlatform = final.makeRustPlatform {
cargo = final.rustToolchain;
rustc = final.rustToolchain;
};
};
};
};
mkPkgs =
system:
import nixpkgs {
inherit system;
overlays = builtins.attrValues overlays;
};
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f (mkPkgs system));
in
{
packages = forAllSystems (pkgs: {
zed-editor = pkgs.zed-editor;
default = pkgs.zed-editor;
});
devShells = forAllSystems (pkgs: {
default = import ./nix/shell.nix { inherit pkgs; };
});
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
overlays = overlays // {
default = nixpkgs.lib.composeManyExtensions (builtins.attrValues overlays);
};
};
}