Add zed-editor package and overlay to flake (#16783)

Adds a `zed-editor` package to the flake, along with exported overlay.
Uses [`crane`](https://crane.dev) to avoid issues with updating
git-sourced dependencies' hashes. Crane will also be useful if we want
to export separate packages for `stable`, `preview`, and `nightly` in
the future.

Release Notes:

- Added a default package + overlay to Zed's Nix flake. This is useful
for users wanting to pilot nightly builds of Zed on NixOS.
This commit is contained in:
jvmncs 2024-08-26 11:10:34 -04:00 committed by GitHub
parent 7936fe40ae
commit 093f131712
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 341 additions and 81 deletions

View file

@ -3,29 +3,53 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ self, nixpkgs }:
let
inherit (self) outputs;
systems = [
"aarch64-linux"
outputs = {
nixpkgs,
crane,
fenix,
...
}: let
forAllSystems = function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
in
{
devShells = forAllSystems (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
default = import ./shell.nix { inherit pkgs; };
}
);
"aarch64-linux"
] (system:
function (import nixpkgs {
inherit system;
overlays = [fenix.overlays.default];
}));
in {
packages = forAllSystems (pkgs: let
craneLib = (crane.mkLib pkgs).overrideToolchain (p: p.fenix.stable.toolchain);
nightlyBuild = pkgs.callPackage ./nix/build.nix {
inherit craneLib;
};
in {
zed-editor = nightlyBuild;
default = nightlyBuild;
});
devShells = forAllSystems (pkgs: {
default = import ./nix/shell.nix {inherit pkgs;};
});
formatter = forAllSystems (pkgs: pkgs.alejandra);
overlays.default = final: _prev: {
zed-editor = final.callPackage ./nix/build.nix {
craneLib = (crane.mkLib final).overrideToolchain (p: p.fenix.stable.toolchain);
};
};
};
}