-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
6 changed files
with
341 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
( | ||
import | ||
( | ||
let | ||
lock = builtins.fromJSON (builtins.readFile ./flake.lock); | ||
in | ||
fetchTarball { | ||
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; | ||
sha256 = lock.nodes.flake-compat.locked.narHash; | ||
} | ||
) | ||
{src = ./.;} | ||
) | ||
.defaultNix |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
{ | ||
lib, | ||
craneLib, | ||
clang, | ||
llvmPackages_18, | ||
mold-wrapped, | ||
copyDesktopItems, | ||
curl, | ||
perl, | ||
pkg-config, | ||
protobuf, | ||
fontconfig, | ||
freetype, | ||
libgit2, | ||
openssl, | ||
sqlite, | ||
zlib, | ||
zstd, | ||
alsa-lib, | ||
libxkbcommon, | ||
wayland, | ||
libglvnd, | ||
xorg, | ||
makeFontsConf, | ||
vulkan-loader, | ||
envsubst, | ||
stdenvAdapters, | ||
nix-gitignore, | ||
withGLES ? false, | ||
}: let | ||
includeFilter = path: type: let | ||
baseName = baseNameOf (toString path); | ||
parentDir = dirOf path; | ||
inRootDir = type == "directory" && parentDir == ../.; | ||
in | ||
!(inRootDir && (baseName == "docs" || baseName == ".github" || baseName == "script" || baseName == ".git" || baseName == "target")); | ||
|
||
src = lib.cleanSourceWith { | ||
src = nix-gitignore.gitignoreSource [] ../.; | ||
filter = includeFilter; | ||
name = "source"; | ||
}; | ||
|
||
stdenv = stdenvAdapters.useMoldLinker llvmPackages_18.stdenv; | ||
|
||
commonArgs = | ||
craneLib.crateNameFromCargoToml {cargoToml = ../crates/zed/Cargo.toml;} | ||
// { | ||
inherit src stdenv; | ||
|
||
buildInputs = [ | ||
curl | ||
fontconfig | ||
freetype | ||
libgit2 | ||
openssl | ||
sqlite | ||
zlib | ||
zstd | ||
alsa-lib | ||
libxkbcommon | ||
wayland | ||
xorg.libxcb | ||
]; | ||
|
||
nativeBuildInputs = [ | ||
clang | ||
copyDesktopItems | ||
curl | ||
mold-wrapped | ||
perl | ||
pkg-config | ||
protobuf | ||
]; | ||
|
||
ZSTD_SYS_USE_PKG_CONFIG = true; | ||
FONTCONFIG_FILE = makeFontsConf { | ||
fontDirectories = [ | ||
"../assets/fonts/zed-mono" | ||
"../assets/fonts/zed-sans" | ||
]; | ||
}; | ||
ZED_UPDATE_EXPLANATION = "zed has been installed using nix. Auto-updates have thus been disabled."; | ||
}; | ||
|
||
cargoArtifacts = craneLib.buildDepsOnly commonArgs; | ||
|
||
gpu-lib = | ||
if withGLES | ||
then libglvnd | ||
else vulkan-loader; | ||
|
||
zed = craneLib.buildPackage (commonArgs | ||
// { | ||
inherit cargoArtifacts; | ||
cargoExtraArgs = "--package=zed --package=cli"; | ||
buildFeatures = ["gpui/runtime_shaders"]; | ||
doCheck = false; | ||
|
||
RUSTFLAGS = | ||
if withGLES | ||
then "--cfg gles" | ||
else ""; | ||
|
||
postFixup = '' | ||
patchelf --add-rpath ${gpu-lib}/lib $out/bin/* | ||
patchelf --add-rpath ${wayland}/lib $out/bin/* | ||
''; | ||
|
||
postInstall = '' | ||
mkdir -p $out/bin $out/libexec | ||
mv $out/bin/zed $out/libexec/zed-editor | ||
mv $out/bin/cli $out/bin/zed | ||
install -D crates/zed/resources/[email protected] $out/share/icons/hicolor/1024x1024@2x/apps/zed.png | ||
install -D crates/zed/resources/app-icon.png $out/share/icons/hicolor/512x512/apps/zed.png | ||
export DO_STARTUP_NOTIFY="true" | ||
export APP_CLI="zed" | ||
export APP_ICON="zed" | ||
export APP_NAME="Zed" | ||
export APP_ARGS="%U" | ||
mkdir -p "$out/share/applications" | ||
${lib.getExe envsubst} < "crates/zed/resources/zed.desktop.in" > "$out/share/applications/dev.zed.Zed.desktop" | ||
''; | ||
}); | ||
in | ||
zed | ||
// { | ||
meta = with lib; { | ||
description = "High-performance, multiplayer code editor from the creators of Atom and Tree-sitter"; | ||
homepage = "https://zed.dev"; | ||
changelog = "https://zed.dev/releases/preview"; | ||
license = licenses.gpl3Only; | ||
mainProgram = "zed"; | ||
platforms = platforms.linux; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{pkgs ? import <nixpkgs> {}}: let | ||
stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.llvmPackages_18.stdenv; | ||
in | ||
if pkgs.stdenv.isDarwin | ||
then | ||
# See https://github.com/NixOS/nixpkgs/issues/320084 | ||
throw "zed: nix dev-shell isn't supported on darwin yet." | ||
else let | ||
buildInputs = with pkgs; [ | ||
curl | ||
fontconfig | ||
freetype | ||
libgit2 | ||
openssl | ||
sqlite | ||
zlib | ||
zstd | ||
alsa-lib | ||
libxkbcommon | ||
wayland | ||
xorg.libxcb | ||
vulkan-loader | ||
]; | ||
in | ||
pkgs.mkShell.override {inherit stdenv;} { | ||
nativeBuildInputs = with pkgs; [ | ||
clang | ||
curl | ||
perl | ||
pkg-config | ||
protobuf | ||
rustPlatform.bindgenHook | ||
]; | ||
|
||
inherit buildInputs; | ||
|
||
shellHook = '' | ||
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath ([ | ||
pkgs.vulkan-loader | ||
] | ||
++ buildInputs)}:$LD_LIBRARY_PATH" | ||
export PROTOC="${pkgs.protobuf}/bin/protoc" | ||
''; | ||
|
||
FONTCONFIG_FILE = pkgs.makeFontsConf { | ||
fontDirectories = [ | ||
"./assets/fonts/zed-mono" | ||
"./assets/fonts/zed-sans" | ||
]; | ||
}; | ||
ZSTD_SYS_USE_PKG_CONFIG = true; | ||
} |
Oops, something went wrong.