2024-04-21 15:54:59 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
rustPlatform,
|
|
|
|
fetchFromGitHub,
|
2024-07-01 15:47:52 +00:00
|
|
|
clang,
|
2024-09-26 11:04:55 +00:00
|
|
|
cmake,
|
2024-04-21 15:54:59 +00:00
|
|
|
copyDesktopItems,
|
|
|
|
curl,
|
2024-06-05 15:53:02 +00:00
|
|
|
perl,
|
2024-04-21 15:54:59 +00:00
|
|
|
pkg-config,
|
|
|
|
protobuf,
|
|
|
|
xcbuild,
|
|
|
|
fontconfig,
|
|
|
|
freetype,
|
|
|
|
libgit2,
|
|
|
|
openssl,
|
|
|
|
sqlite,
|
|
|
|
zlib,
|
|
|
|
zstd,
|
|
|
|
alsa-lib,
|
|
|
|
libxkbcommon,
|
|
|
|
wayland,
|
2024-06-24 18:47:55 +00:00
|
|
|
libglvnd,
|
2024-04-21 15:54:59 +00:00
|
|
|
xorg,
|
|
|
|
stdenv,
|
|
|
|
darwin,
|
|
|
|
makeFontsConf,
|
|
|
|
vulkan-loader,
|
2024-07-01 15:47:52 +00:00
|
|
|
envsubst,
|
|
|
|
nix-update-script,
|
2024-09-19 14:19:46 +00:00
|
|
|
cargo-about,
|
|
|
|
testers,
|
|
|
|
zed-editor,
|
|
|
|
buildFHSEnv,
|
2024-06-24 18:47:55 +00:00
|
|
|
|
2024-07-01 15:47:52 +00:00
|
|
|
withGLES ? false,
|
2024-04-21 15:54:59 +00:00
|
|
|
}:
|
|
|
|
|
2024-09-26 11:04:55 +00:00
|
|
|
assert withGLES -> stdenv.hostPlatform.isLinux;
|
2024-06-24 18:47:55 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
let
|
2024-09-26 11:04:55 +00:00
|
|
|
executableName = "zeditor";
|
2024-09-19 14:19:46 +00:00
|
|
|
# Based on vscode.fhs
|
|
|
|
# Zed allows for users to download and use extensions
|
|
|
|
# which often include the usage of pre-built binaries.
|
|
|
|
# See #309662
|
|
|
|
#
|
|
|
|
# buildFHSEnv allows for users to use the existing Zed
|
|
|
|
# extension tooling without significant pain.
|
|
|
|
fhs =
|
|
|
|
{
|
|
|
|
additionalPkgs ? pkgs: [ ],
|
|
|
|
}:
|
|
|
|
buildFHSEnv {
|
|
|
|
# also determines the name of the wrapped command
|
|
|
|
name = executableName;
|
|
|
|
|
|
|
|
# additional libraries which are commonly needed for extensions
|
|
|
|
targetPkgs =
|
|
|
|
pkgs:
|
|
|
|
(with pkgs; [
|
|
|
|
# ld-linux-x86-64-linux.so.2 and others
|
|
|
|
glibc
|
|
|
|
])
|
|
|
|
++ additionalPkgs pkgs;
|
|
|
|
|
|
|
|
# symlink shared assets, including icons and desktop entries
|
|
|
|
extraInstallCommands = ''
|
|
|
|
ln -s "${zed-editor}/share" "$out/"
|
|
|
|
'';
|
|
|
|
|
|
|
|
runScript = "${zed-editor}/bin/${executableName}";
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
inherit executableName;
|
|
|
|
inherit (zed-editor) pname version;
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = zed-editor.meta // {
|
|
|
|
description = ''
|
|
|
|
Wrapped variant of ${zed-editor.pname} which launches in a FHS compatible environment.
|
|
|
|
Should allow for easy usage of extensions without nix-specific modifications.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
2024-04-21 15:54:59 +00:00
|
|
|
rustPlatform.buildRustPackage rec {
|
2024-09-26 11:04:55 +00:00
|
|
|
pname = "zed-editor";
|
|
|
|
version = "0.154.1";
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "zed-industries";
|
|
|
|
repo = "zed";
|
|
|
|
rev = "refs/tags/v${version}";
|
2024-09-26 11:04:55 +00:00
|
|
|
hash = "sha256-ZYaWkmLWhmGM7muU70JqD5HjgsI+oaouilqjUYUQcg8=";
|
2024-04-21 15:54:59 +00:00
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
patches = [
|
|
|
|
# Zed uses cargo-install to install cargo-about during the script execution.
|
|
|
|
# We provide cargo-about ourselves and can skip this step.
|
|
|
|
./0001-generate-licenses.patch
|
|
|
|
];
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
cargoLock = {
|
|
|
|
lockFile = ./Cargo.lock;
|
|
|
|
outputHashes = {
|
2024-09-19 14:19:46 +00:00
|
|
|
"alacritty_terminal-0.24.1-dev" = "sha256-b4oSDhsAAYjpYGfFgA1Q1642JoJQ9k5RTsPgFUpAFmc=";
|
2024-04-21 15:54:59 +00:00
|
|
|
"async-pipe-0.1.3" = "sha256-g120X88HGT8P6GNCrzpS5SutALx5H+45Sf4iSSxzctE=";
|
2024-09-19 14:19:46 +00:00
|
|
|
"blade-graphics-0.5.0" = "sha256-j/JI34ZPD7RAHNHu3krgDLnIq4QmmZaZaU1FwD7f2FM=";
|
2024-07-01 15:47:52 +00:00
|
|
|
"cosmic-text-0.11.2" = "sha256-TLPDnqixuW+aPAhiBhSvuZIa69vgV3xLcw32OlkdCcM=";
|
2024-09-19 14:19:46 +00:00
|
|
|
"font-kit-0.14.1" = "sha256-qUKvmi+RDoyhMrZ7T6SoVAyMc/aasQ9Y/okzre4SzXo=";
|
2024-07-01 15:47:52 +00:00
|
|
|
"lsp-types-0.95.1" = "sha256-N4MKoU9j1p/Xeowki/+XiNQPwIcTm9DgmfM/Eieq4js=";
|
2024-09-19 14:19:46 +00:00
|
|
|
"nvim-rs-0.8.0-pre" = "sha256-VA8zIynflul1YKBlSxGCXCwa2Hz0pT3mH6OPsfS7Izo=";
|
2024-09-26 11:04:55 +00:00
|
|
|
"protols-tree-sitter-proto-0.2.0" = "sha256-0pvHuwqtkHYLevQnaEFmfyDtILD7Wy0in2KSKFR2mKw=";
|
|
|
|
"tree-sitter-gomod-1.0.2" = "sha256-FCb8ndKSFiLY7/nTX7tWF8c4KcSvoBU1QB5R4rdOgT0=";
|
|
|
|
"tree-sitter-gowork-0.0.1" = "sha256-WRMgGjOlJ+bT/YnSBeSLRTLlltA5WwTvV0Ow/949+BE=";
|
|
|
|
"tree-sitter-heex-0.0.1" = "sha256-SnjhL0WVsHOKuUp3dkTETnCgC/Z7WN0XmpQdJPBeBhw=";
|
|
|
|
"tree-sitter-md-0.3.2" = "sha256-sFcQDabSay9qxzVNAQkHEZB1b9j171dDoYQqaL1iVhE=";
|
|
|
|
"tree-sitter-yaml-0.6.1" = "sha256-95u/bq74SiUHW8lVp3RpanmYS/lyVPW0Inn8gR7N3IQ=";
|
|
|
|
"xim-0.4.0" = "sha256-BXyaIBoqMNbzaSJqMadmofdjtlEVSoU6iogF66YP6a4=";
|
2024-07-31 10:19:44 +00:00
|
|
|
"xkbcommon-0.7.0" = "sha256-2RjZWiAaz8apYTrZ82qqH4Gv20WyCtPT+ldOzm0GWMo=";
|
2024-04-21 15:54:59 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2024-07-01 15:47:52 +00:00
|
|
|
clang
|
2024-09-26 11:04:55 +00:00
|
|
|
cmake
|
2024-04-21 15:54:59 +00:00
|
|
|
copyDesktopItems
|
|
|
|
curl
|
2024-06-05 15:53:02 +00:00
|
|
|
perl
|
2024-04-21 15:54:59 +00:00
|
|
|
pkg-config
|
|
|
|
protobuf
|
|
|
|
rustPlatform.bindgenHook
|
2024-09-19 14:19:46 +00:00
|
|
|
cargo-about
|
2024-09-26 11:04:55 +00:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcbuild.xcrun ];
|
|
|
|
|
|
|
|
dontUseCmakeConfigure = true;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
buildInputs =
|
|
|
|
[
|
|
|
|
curl
|
|
|
|
fontconfig
|
|
|
|
freetype
|
|
|
|
libgit2
|
|
|
|
openssl
|
|
|
|
sqlite
|
|
|
|
zlib
|
|
|
|
zstd
|
|
|
|
]
|
2024-09-26 11:04:55 +00:00
|
|
|
++ lib.optionals stdenv.hostPlatform.isLinux [
|
2024-04-21 15:54:59 +00:00
|
|
|
alsa-lib
|
|
|
|
libxkbcommon
|
|
|
|
wayland
|
|
|
|
xorg.libxcb
|
|
|
|
]
|
2024-09-26 11:04:55 +00:00
|
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin (
|
2024-04-21 15:54:59 +00:00
|
|
|
with darwin.apple_sdk.frameworks;
|
|
|
|
[
|
|
|
|
AppKit
|
|
|
|
CoreAudio
|
|
|
|
CoreFoundation
|
|
|
|
CoreGraphics
|
|
|
|
CoreMedia
|
|
|
|
CoreServices
|
|
|
|
CoreText
|
|
|
|
Foundation
|
|
|
|
IOKit
|
|
|
|
Metal
|
|
|
|
Security
|
|
|
|
SystemConfiguration
|
|
|
|
VideoToolbox
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
cargoBuildFlags = [
|
|
|
|
"--package=zed"
|
|
|
|
"--package=cli"
|
|
|
|
];
|
2024-04-21 15:54:59 +00:00
|
|
|
buildFeatures = [ "gpui/runtime_shaders" ];
|
|
|
|
|
|
|
|
env = {
|
|
|
|
ZSTD_SYS_USE_PKG_CONFIG = true;
|
|
|
|
FONTCONFIG_FILE = makeFontsConf {
|
|
|
|
fontDirectories = [
|
2024-09-19 14:19:46 +00:00
|
|
|
"${src}/assets/fonts/plex-mono"
|
|
|
|
"${src}/assets/fonts/plex-sans"
|
2024-04-21 15:54:59 +00:00
|
|
|
];
|
|
|
|
};
|
2024-09-19 14:19:46 +00:00
|
|
|
# Setting this environment variable allows to disable auto-updates
|
|
|
|
# https://zed.dev/docs/development/linux#notes-for-packaging-zed
|
|
|
|
ZED_UPDATE_EXPLANATION = "zed has been installed using nix. Auto-updates have thus been disabled.";
|
|
|
|
# Used by `zed --version`
|
|
|
|
RELEASE_VERSION = version;
|
2024-04-21 15:54:59 +00:00
|
|
|
};
|
|
|
|
|
2024-06-24 18:47:55 +00:00
|
|
|
RUSTFLAGS = if withGLES then "--cfg gles" else "";
|
|
|
|
gpu-lib = if withGLES then libglvnd else vulkan-loader;
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
preBuild = ''
|
|
|
|
bash script/generate-licenses
|
|
|
|
'';
|
|
|
|
|
2024-09-26 11:04:55 +00:00
|
|
|
postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
|
2024-07-27 06:49:29 +00:00
|
|
|
patchelf --add-rpath ${gpu-lib}/lib $out/libexec/*
|
|
|
|
patchelf --add-rpath ${wayland}/lib $out/libexec/*
|
2024-04-21 15:54:59 +00:00
|
|
|
'';
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
preCheck = ''
|
|
|
|
export HOME=$(mktemp -d);
|
|
|
|
'';
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
checkFlags = lib.optionals stdenv.hostPlatform.isLinux [
|
2024-06-05 15:53:02 +00:00
|
|
|
# Fails on certain hosts (including Hydra) for unclear reason
|
|
|
|
"--skip=test_open_paths_action"
|
2024-09-19 14:19:46 +00:00
|
|
|
|
|
|
|
# Flaky: unreliably fails on certain hosts (including Hydra)
|
|
|
|
"--skip=zed::tests::test_window_edit_state_restoring_enabled"
|
2024-04-21 15:54:59 +00:00
|
|
|
];
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/bin $out/libexec
|
|
|
|
cp target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/zed $out/libexec/zed-editor
|
2024-09-26 11:04:55 +00:00
|
|
|
cp target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/cli $out/bin/zeditor
|
2024-07-27 06:49:29 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
install -D ${src}/crates/zed/resources/app-icon@2x.png $out/share/icons/hicolor/1024x1024@2x/apps/zed.png
|
|
|
|
install -D ${src}/crates/zed/resources/app-icon.png $out/share/icons/hicolor/512x512/apps/zed.png
|
2024-07-01 15:47:52 +00:00
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
# extracted from https://github.com/zed-industries/zed/blob/v0.141.2/script/bundle-linux (envsubst)
|
|
|
|
# and https://github.com/zed-industries/zed/blob/v0.141.2/script/install.sh (final desktop file name)
|
2024-07-01 15:47:52 +00:00
|
|
|
(
|
|
|
|
export DO_STARTUP_NOTIFY="true"
|
2024-09-26 11:04:55 +00:00
|
|
|
export APP_CLI="zeditor"
|
2024-07-01 15:47:52 +00:00
|
|
|
export APP_ICON="zed"
|
|
|
|
export APP_NAME="Zed"
|
2024-07-27 06:49:29 +00:00
|
|
|
export APP_ARGS="%U"
|
2024-07-01 15:47:52 +00:00
|
|
|
mkdir -p "$out/share/applications"
|
2024-07-27 06:49:29 +00:00
|
|
|
${lib.getExe envsubst} < "crates/zed/resources/zed.desktop.in" > "$out/share/applications/dev.zed.Zed.desktop"
|
2024-07-01 15:47:52 +00:00
|
|
|
)
|
2024-07-27 06:49:29 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
2024-04-21 15:54:59 +00:00
|
|
|
'';
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
passthru = {
|
|
|
|
updateScript = nix-update-script {
|
|
|
|
extraArgs = [
|
|
|
|
"--version-regex"
|
|
|
|
"v(.*)"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
tests.version = testers.testVersion {
|
|
|
|
inherit version;
|
|
|
|
package = zed-editor;
|
|
|
|
};
|
|
|
|
fhs = fhs { };
|
|
|
|
fhsWithPackages = f: fhs { additionalPkgs = f; };
|
2024-07-01 15:47:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
meta = {
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "High-performance, multiplayer code editor from the creators of Atom and Tree-sitter";
|
|
|
|
homepage = "https://zed.dev";
|
|
|
|
changelog = "https://github.com/zed-industries/zed/releases/tag/v${version}";
|
2024-07-01 15:47:52 +00:00
|
|
|
license = lib.licenses.gpl3Only;
|
|
|
|
maintainers = with lib.maintainers; [
|
2024-04-21 15:54:59 +00:00
|
|
|
GaetanLepage
|
|
|
|
niklaskorz
|
|
|
|
];
|
2024-09-26 11:04:55 +00:00
|
|
|
mainProgram = "zeditor";
|
2024-07-01 15:47:52 +00:00
|
|
|
platforms = lib.platforms.all;
|
2024-04-21 15:54:59 +00:00
|
|
|
# Currently broken on darwin: https://github.com/NixOS/nixpkgs/pull/303233#issuecomment-2048650618
|
2024-09-26 11:04:55 +00:00
|
|
|
broken = stdenv.hostPlatform.isDarwin;
|
2024-04-21 15:54:59 +00:00
|
|
|
};
|
|
|
|
}
|