nix: Clean up build (#27881)
- bump our livekit version to include a fix for a crane bug (TODO: add link when an issue is filed on crane) - switch to a clang stdenv for both linux and macos - manually unify versions of our notify crate - remove old linker flags which were only needed for livekit - fix an issue where RUSTFLAGS shadowed the rustflags from cargo configs Release Notes: - N/A
This commit is contained in:
parent
a1b53e91e7
commit
4110928314
@ -14,10 +14,10 @@ linker = "clang"
|
||||
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
|
||||
|
||||
[target.aarch64-apple-darwin]
|
||||
rustflags = ["-C", "link-args=-Objc -all_load"]
|
||||
rustflags = ["-C", "link-args=-all_load"]
|
||||
|
||||
[target.x86_64-apple-darwin]
|
||||
rustflags = ["-C", "link-args=-Objc -all_load"]
|
||||
rustflags = ["-C", "link-args=-all_load"]
|
||||
|
||||
[target.'cfg(target_os = "windows")']
|
||||
rustflags = [
|
||||
|
3
.github/workflows/release_nightly.yml
vendored
3
.github/workflows/release_nightly.yml
vendored
@ -184,9 +184,6 @@ jobs:
|
||||
- os: arm Mac
|
||||
runner: [macOS, ARM64, test]
|
||||
install_nix: false
|
||||
- os: arm Linux
|
||||
runner: buildjet-16vcpu-ubuntu-2204-arm
|
||||
install_nix: true
|
||||
if: github.repository_owner == 'zed-industries'
|
||||
runs-on: ${{ matrix.system.runner }}
|
||||
needs: tests
|
||||
|
52
Cargo.lock
generated
52
Cargo.lock
generated
@ -5309,7 +5309,7 @@ dependencies = [
|
||||
"ignore",
|
||||
"libc",
|
||||
"log",
|
||||
"notify 8.0.0 (git+https://github.com/zed-industries/notify.git?rev=bbb9ea5ae52b253e095737847e367c30653a2e96)",
|
||||
"notify",
|
||||
"objc",
|
||||
"parking_lot",
|
||||
"paths",
|
||||
@ -7717,7 +7717,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "libwebrtc"
|
||||
version = "0.3.10"
|
||||
source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=102ebbb1ccfbdbcb7332d86dc30b1b1c8c01e4f8#102ebbb1ccfbdbcb7332d86dc30b1b1c8c01e4f8"
|
||||
source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=ffc215666621cd903a689d1c56cce0a706ffe022#ffc215666621cd903a689d1c56cce0a706ffe022"
|
||||
dependencies = [
|
||||
"cxx",
|
||||
"jni",
|
||||
@ -7802,7 +7802,7 @@ checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104"
|
||||
[[package]]
|
||||
name = "livekit"
|
||||
version = "0.7.8"
|
||||
source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=102ebbb1ccfbdbcb7332d86dc30b1b1c8c01e4f8#102ebbb1ccfbdbcb7332d86dc30b1b1c8c01e4f8"
|
||||
source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=ffc215666621cd903a689d1c56cce0a706ffe022#ffc215666621cd903a689d1c56cce0a706ffe022"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"futures-util",
|
||||
@ -7825,12 +7825,10 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "livekit-api"
|
||||
version = "0.4.2"
|
||||
source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=102ebbb1ccfbdbcb7332d86dc30b1b1c8c01e4f8#102ebbb1ccfbdbcb7332d86dc30b1b1c8c01e4f8"
|
||||
source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=ffc215666621cd903a689d1c56cce0a706ffe022#ffc215666621cd903a689d1c56cce0a706ffe022"
|
||||
dependencies = [
|
||||
"base64 0.21.7",
|
||||
"futures-util",
|
||||
"http 0.2.12",
|
||||
"jsonwebtoken",
|
||||
"livekit-protocol",
|
||||
"livekit-runtime",
|
||||
"log",
|
||||
@ -7841,7 +7839,6 @@ dependencies = [
|
||||
"reqwest 0.11.27",
|
||||
"scopeguard",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"thiserror 1.0.69",
|
||||
"tokio",
|
||||
@ -7852,7 +7849,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "livekit-protocol"
|
||||
version = "0.3.9"
|
||||
source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=102ebbb1ccfbdbcb7332d86dc30b1b1c8c01e4f8#102ebbb1ccfbdbcb7332d86dc30b1b1c8c01e4f8"
|
||||
source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=ffc215666621cd903a689d1c56cce0a706ffe022#ffc215666621cd903a689d1c56cce0a706ffe022"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"livekit-runtime",
|
||||
@ -7869,7 +7866,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "livekit-runtime"
|
||||
version = "0.4.0"
|
||||
source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=102ebbb1ccfbdbcb7332d86dc30b1b1c8c01e4f8#102ebbb1ccfbdbcb7332d86dc30b1b1c8c01e4f8"
|
||||
source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=ffc215666621cd903a689d1c56cce0a706ffe022#ffc215666621cd903a689d1c56cce0a706ffe022"
|
||||
dependencies = [
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
@ -8239,7 +8236,7 @@ dependencies = [
|
||||
"ignore",
|
||||
"log",
|
||||
"memchr",
|
||||
"notify 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"notify",
|
||||
"notify-debouncer-mini",
|
||||
"once_cell",
|
||||
"opener",
|
||||
@ -8666,25 +8663,6 @@ dependencies = [
|
||||
"workspace",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "notify"
|
||||
version = "8.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fee8403b3d66ac7b26aee6e40a897d85dc5ce26f44da36b8b73e987cc52e943"
|
||||
dependencies = [
|
||||
"bitflags 2.9.0",
|
||||
"filetime",
|
||||
"fsevent-sys 4.1.0",
|
||||
"inotify",
|
||||
"kqueue",
|
||||
"libc",
|
||||
"log",
|
||||
"mio",
|
||||
"notify-types 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"walkdir",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "notify"
|
||||
version = "8.0.0"
|
||||
@ -8698,7 +8676,7 @@ dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"mio",
|
||||
"notify-types 2.0.0 (git+https://github.com/zed-industries/notify.git?rev=bbb9ea5ae52b253e095737847e367c30653a2e96)",
|
||||
"notify-types",
|
||||
"walkdir",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
@ -8710,17 +8688,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a689eb4262184d9a1727f9087cd03883ea716682ab03ed24efec57d7716dccb8"
|
||||
dependencies = [
|
||||
"log",
|
||||
"notify 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"notify-types 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"notify",
|
||||
"notify-types",
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "notify-types"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d"
|
||||
|
||||
[[package]]
|
||||
name = "notify-types"
|
||||
version = "2.0.0"
|
||||
@ -16191,7 +16163,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "webrtc-sys"
|
||||
version = "0.3.7"
|
||||
source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=102ebbb1ccfbdbcb7332d86dc30b1b1c8c01e4f8#102ebbb1ccfbdbcb7332d86dc30b1b1c8c01e4f8"
|
||||
source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=ffc215666621cd903a689d1c56cce0a706ffe022#ffc215666621cd903a689d1c56cce0a706ffe022"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cxx",
|
||||
@ -16204,7 +16176,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "webrtc-sys-build"
|
||||
version = "0.3.6"
|
||||
source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=102ebbb1ccfbdbcb7332d86dc30b1b1c8c01e4f8#102ebbb1ccfbdbcb7332d86dc30b1b1c8c01e4f8"
|
||||
source = "git+https://github.com/zed-industries/livekit-rust-sdks?rev=ffc215666621cd903a689d1c56cce0a706ffe022#ffc215666621cd903a689d1c56cce0a706ffe022"
|
||||
dependencies = [
|
||||
"fs2",
|
||||
"regex",
|
||||
|
@ -657,6 +657,8 @@ features = [
|
||||
[patch.crates-io]
|
||||
cpal = { git = "https://github.com/zed-industries/cpal", rev = "fd8bc2fd39f1f5fdee5a0690656caff9a26d9d50" }
|
||||
real-async-tls = { git = "https://github.com/zed-industries/async-tls", rev = "1e759a4b5e370f87dc15e40756ac4f8815b61d9d", package = "async-tls" }
|
||||
notify = { git = "https://github.com/zed-industries/notify.git", rev = "bbb9ea5ae52b253e095737847e367c30653a2e96" }
|
||||
notify-types = { git = "https://github.com/zed-industries/notify.git", rev = "bbb9ea5ae52b253e095737847e367c30653a2e96" }
|
||||
|
||||
[profile.dev]
|
||||
split-debuginfo = "unpacked"
|
||||
|
@ -40,7 +40,7 @@ objc = "0.2"
|
||||
cocoa = "0.26"
|
||||
|
||||
[target.'cfg(not(target_os = "macos"))'.dependencies]
|
||||
notify = { git = "https://github.com/zed-industries/notify.git", rev = "bbb9ea5ae52b253e095737847e367c30653a2e96" }
|
||||
notify = "8.0.0"
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
windows.workspace = true
|
||||
|
@ -1,2 +0,0 @@
|
||||
[livekit_client_test]
|
||||
rustflags = ["-C", "link-args=-ObjC"]
|
@ -39,8 +39,8 @@ tokio-tungstenite.workspace = true
|
||||
util.workspace = true
|
||||
|
||||
[target.'cfg(not(all(target_os = "windows", target_env = "gnu")))'.dependencies]
|
||||
libwebrtc = { rev = "102ebbb1ccfbdbcb7332d86dc30b1b1c8c01e4f8", git = "https://github.com/zed-industries/livekit-rust-sdks" }
|
||||
livekit = { rev = "102ebbb1ccfbdbcb7332d86dc30b1b1c8c01e4f8", git = "https://github.com/zed-industries/livekit-rust-sdks", features = ["__rustls-tls"] }
|
||||
libwebrtc = { rev = "ffc215666621cd903a689d1c56cce0a706ffe022", git = "https://github.com/zed-industries/livekit-rust-sdks" }
|
||||
livekit = { rev = "ffc215666621cd903a689d1c56cce0a706ffe022", git = "https://github.com/zed-industries/livekit-rust-sdks", features = ["__rustls-tls"] }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
core-foundation.workspace = true
|
||||
|
110
nix/build.nix
110
nix/build.nix
@ -1,48 +1,49 @@
|
||||
{
|
||||
lib,
|
||||
crane,
|
||||
rustToolchain,
|
||||
rustPlatform,
|
||||
cmake,
|
||||
copyDesktopItems,
|
||||
fetchFromGitHub,
|
||||
curl,
|
||||
clang,
|
||||
perl,
|
||||
pkg-config,
|
||||
protobuf,
|
||||
fontconfig,
|
||||
freetype,
|
||||
libgit2,
|
||||
openssl,
|
||||
sqlite,
|
||||
zlib,
|
||||
zstd,
|
||||
alsa-lib,
|
||||
libxkbcommon,
|
||||
wayland,
|
||||
libglvnd,
|
||||
xorg,
|
||||
stdenv,
|
||||
makeFontsConf,
|
||||
vulkan-loader,
|
||||
envsubst,
|
||||
cargo-about,
|
||||
cargo-bundle,
|
||||
git,
|
||||
livekit-libwebrtc,
|
||||
|
||||
apple-sdk_15,
|
||||
darwin,
|
||||
darwinMinVersionHook,
|
||||
|
||||
cargo-about,
|
||||
cargo-bundle,
|
||||
crane,
|
||||
rustPlatform,
|
||||
rustToolchain,
|
||||
|
||||
copyDesktopItems,
|
||||
envsubst,
|
||||
fetchFromGitHub,
|
||||
makeFontsConf,
|
||||
makeWrapper,
|
||||
|
||||
alsa-lib,
|
||||
cmake,
|
||||
curl,
|
||||
fontconfig,
|
||||
freetype,
|
||||
git,
|
||||
libgit2,
|
||||
libglvnd,
|
||||
libxkbcommon,
|
||||
livekit-libwebrtc,
|
||||
nodejs_22,
|
||||
openssl,
|
||||
perl,
|
||||
pkg-config,
|
||||
protobuf,
|
||||
sqlite,
|
||||
vulkan-loader,
|
||||
wayland,
|
||||
xorg,
|
||||
zlib,
|
||||
zstd,
|
||||
|
||||
withGLES ? false,
|
||||
profile ? "release",
|
||||
}:
|
||||
|
||||
assert withGLES -> stdenv.hostPlatform.isLinux;
|
||||
|
||||
let
|
||||
mkIncludeFilter =
|
||||
root': path: type:
|
||||
@ -58,6 +59,7 @@ let
|
||||
"tooling"
|
||||
"Cargo.toml"
|
||||
".config" # nextest?
|
||||
".cargo"
|
||||
];
|
||||
firstComp = builtins.head (lib.path.subpath.components relPath);
|
||||
in
|
||||
@ -68,6 +70,7 @@ let
|
||||
commonArgs =
|
||||
let
|
||||
zedCargoLock = builtins.fromTOML (builtins.readFile ../crates/zed/Cargo.toml);
|
||||
stdenv' = stdenv;
|
||||
in
|
||||
rec {
|
||||
pname = "zed-editor";
|
||||
@ -82,7 +85,6 @@ let
|
||||
|
||||
nativeBuildInputs =
|
||||
[
|
||||
clang # TODO: use pkgs.clangStdenv or ignore cargo config?
|
||||
cmake
|
||||
copyDesktopItems
|
||||
curl
|
||||
@ -92,8 +94,8 @@ let
|
||||
cargo-about
|
||||
rustPlatform.bindgenHook
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isLinux [ makeWrapper ]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
++ lib.optionals stdenv'.hostPlatform.isLinux [ makeWrapper ]
|
||||
++ lib.optionals stdenv'.hostPlatform.isDarwin [
|
||||
# TODO: move to overlay so it's usable in the shell
|
||||
(cargo-bundle.overrideAttrs (
|
||||
new: old: {
|
||||
@ -128,14 +130,14 @@ let
|
||||
zlib
|
||||
zstd
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isLinux [
|
||||
++ lib.optionals stdenv'.hostPlatform.isLinux [
|
||||
alsa-lib
|
||||
libxkbcommon
|
||||
wayland
|
||||
gpu-lib
|
||||
xorg.libxcb
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
++ lib.optionals stdenv'.hostPlatform.isDarwin [
|
||||
apple-sdk_15
|
||||
darwin.apple_sdk.frameworks.System
|
||||
(darwinMinVersionHook "10.15")
|
||||
@ -143,6 +145,22 @@ let
|
||||
|
||||
cargoExtraArgs = "-p zed -p cli --locked --features=gpui/runtime_shaders";
|
||||
|
||||
stdenv =
|
||||
pkgs:
|
||||
let
|
||||
base = pkgs.llvmPackages.stdenv;
|
||||
addBinTools = old: {
|
||||
cc = old.cc.override {
|
||||
inherit (pkgs.llvmPackages) bintools;
|
||||
};
|
||||
};
|
||||
custom = lib.pipe base [
|
||||
(stdenv: stdenv.override addBinTools)
|
||||
pkgs.stdenvAdapters.useMoldLinker
|
||||
];
|
||||
in
|
||||
if stdenv'.hostPlatform.isLinux then custom else base;
|
||||
|
||||
env = {
|
||||
ZSTD_SYS_USE_PKG_CONFIG = true;
|
||||
FONTCONFIG_FILE = makeFontsConf {
|
||||
@ -153,7 +171,6 @@ let
|
||||
};
|
||||
ZED_UPDATE_EXPLANATION = "Zed has been installed using Nix. Auto-updates have thus been disabled.";
|
||||
RELEASE_VERSION = version;
|
||||
RUSTFLAGS = if withGLES then "--cfg gles" else "";
|
||||
LK_CUSTOM_WEBRTC = livekit-libwebrtc;
|
||||
|
||||
CARGO_PROFILE = profile;
|
||||
@ -162,7 +179,7 @@ let
|
||||
|
||||
# for some reason these deps being in buildInputs isn't enough, the only thing
|
||||
# about them that's special is that they're manually dlopened at runtime
|
||||
NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isLinux "-rpath ${
|
||||
NIX_LDFLAGS = lib.optionalString stdenv'.hostPlatform.isLinux "-rpath ${
|
||||
lib.makeLibraryPath [
|
||||
gpu-lib
|
||||
wayland
|
||||
@ -171,7 +188,7 @@ let
|
||||
};
|
||||
|
||||
# prevent nix from removing the "unused" wayland/gpu-lib rpaths
|
||||
dontPatchELF = stdenv.hostPlatform.isLinux;
|
||||
dontPatchELF = stdenv'.hostPlatform.isLinux;
|
||||
|
||||
# TODO: try craneLib.cargoNextest separate output
|
||||
# for now we're not worried about running our test suite (or tests for deps) in the nix sandbox
|
||||
@ -182,12 +199,23 @@ let
|
||||
overrideVendorGitCheckout =
|
||||
let
|
||||
hasWebRtcSys = builtins.any (crate: crate.name == "webrtc-sys");
|
||||
# we can't set $RUSTFLAGS because that clobbers the cargo config
|
||||
# see https://github.com/rust-lang/cargo/issues/5376#issuecomment-2163350032
|
||||
glesConfig = builtins.toFile "config.toml" ''
|
||||
[target.'cfg(all())']
|
||||
rustflags = ["--cfg", "gles"]
|
||||
'';
|
||||
|
||||
# `webrtc-sys` expects a staticlib; nixpkgs' `livekit-webrtc` has been patched to
|
||||
# produce a `dylib`... patching `webrtc-sys`'s build script is the easier option
|
||||
# TODO: send livekit sdk a PR to make this configurable
|
||||
postPatch = ''
|
||||
postPatch =
|
||||
''
|
||||
substituteInPlace webrtc-sys/build.rs --replace-fail \
|
||||
"cargo:rustc-link-lib=static=webrtc" "cargo:rustc-link-lib=dylib=webrtc"
|
||||
''
|
||||
+ lib.optionalString withGLES ''
|
||||
cat ${glesConfig} >> .cargo/config/config.toml
|
||||
'';
|
||||
in
|
||||
crates: drv:
|
||||
|
@ -1,7 +1,5 @@
|
||||
{
|
||||
mkShell,
|
||||
stdenv,
|
||||
stdenvAdapters,
|
||||
makeFontsConf,
|
||||
|
||||
zed-editor,
|
||||
@ -12,12 +10,7 @@
|
||||
protobuf,
|
||||
nodejs_22,
|
||||
}:
|
||||
let
|
||||
moldStdenv = stdenvAdapters.useMoldLinker stdenv;
|
||||
mkShell' =
|
||||
if stdenv.hostPlatform.isLinux then mkShell.override { stdenv = moldStdenv; } else mkShell;
|
||||
in
|
||||
mkShell' {
|
||||
(mkShell.override { inherit (zed-editor) stdenv; }) {
|
||||
inputsFrom = [ zed-editor ];
|
||||
packages = [
|
||||
rust-analyzer
|
||||
|
Loading…
Reference in New Issue
Block a user