From fae59b86590e99c0bd22a1519f50c3e4f4c14680 Mon Sep 17 00:00:00 2001 From: iamnbutler Date: Fri, 12 Dec 2025 14:29:48 -0500 Subject: [PATCH] Remove Zed-specific Nix configuration The nix/flake configuration was for building the Zed editor, not for GPUI as a library. A new Nix configuration can be added later if needed for GPUI development. --- default.nix | 11 -- flake.lock | 77 ------------ flake.nix | 66 ----------- nix/build.nix | 321 -------------------------------------------------- nix/shell.nix | 63 ---------- shell.nix | 11 -- 6 files changed, 549 deletions(-) delete mode 100644 default.nix delete mode 100644 flake.lock delete mode 100644 flake.nix delete mode 100644 nix/build.nix delete mode 100644 nix/shell.nix delete mode 100644 shell.nix diff --git a/default.nix b/default.nix deleted file mode 100644 index 1d976a3576..0000000000 --- a/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -(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 diff --git a/flake.lock b/flake.lock deleted file mode 100644 index 3074b947ef..0000000000 --- a/flake.lock +++ /dev/null @@ -1,77 +0,0 @@ -{ - "nodes": { - "crane": { - "locked": { - "lastModified": 1762538466, - "narHash": "sha256-8zrIPl6J+wLm9MH5ksHcW7BUHo7jSNOu0/hA0ohOOaM=", - "owner": "ipetkov", - "repo": "crane", - "rev": "0cea393fffb39575c46b7a0318386467272182fe", - "type": "github" - }, - "original": { - "owner": "ipetkov", - "repo": "crane", - "type": "github" - } - }, - "flake-compat": { - "locked": { - "lastModified": 1761588595, - "narHash": "sha256-XKUZz9zewJNUj46b4AJdiRZJAvSZ0Dqj2BNfXvFlJC4=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 315532800, - "narHash": "sha256-5CwQ80ucRHiqVbMEEbTFnjz70/axSJ0aliyzSaFSkmY=", - "rev": "f6b44b2401525650256b977063dbcf830f762369", - "type": "tarball", - "url": "https://releases.nixos.org/nixpkgs/nixpkgs-25.11pre891648.f6b44b240152/nixexprs.tar.xz" - }, - "original": { - "type": "tarball", - "url": "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz" - } - }, - "root": { - "inputs": { - "crane": "crane", - "flake-compat": "flake-compat", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" - } - }, - "rust-overlay": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1762915112, - "narHash": "sha256-d9j1g8nKmYDHy+/bIOPQTh9IwjRliqaTM0QLHMV92Ic=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "aa1e85921cfa04de7b6914982a94621fbec5cc02", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index fe7a09701b..0000000000 --- a/flake.nix +++ /dev/null @@ -1,66 +0,0 @@ -{ - description = "High-performance, multiplayer code editor from the creators of Atom and Tree-sitter"; - - inputs = { - nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"; - rust-overlay = { - url = "github:oxalica/rust-overlay"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - crane.url = "github:ipetkov/crane"; - flake-compat.url = "github:edolstra/flake-compat"; - }; - - outputs = - { - nixpkgs, - rust-overlay, - crane, - ... - }: - let - systems = [ - "x86_64-linux" - "x86_64-darwin" - "aarch64-linux" - "aarch64-darwin" - ]; - - forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); - mkZed = - pkgs: - let - rustBin = rust-overlay.lib.mkRustBin { } pkgs; - in - pkgs.callPackage ./nix/build.nix { - crane = crane.mkLib pkgs; - rustToolchain = rustBin.fromRustupToolchainFile ./rust-toolchain.toml; - }; - in - rec { - packages = forAllSystems (pkgs: rec { - default = mkZed pkgs; - debug = default.override { profile = "dev"; }; - }); - devShells = forAllSystems (pkgs: { - default = pkgs.callPackage ./nix/shell.nix { - zed-editor = packages.${pkgs.hostPlatform.system}.default; - }; - }); - formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style); - overlays.default = final: _: { - zed-editor = mkZed final; - }; - }; - - nixConfig = { - extra-substituters = [ - "https://zed.cachix.org" - "https://cache.garnix.io" - ]; - extra-trusted-public-keys = [ - "zed.cachix.org-1:/pHQ6dpMsAZk2DiP4WCL0p9YDNKWj2Q5FL20bNmw1cU=" - "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" - ]; - }; -} diff --git a/nix/build.nix b/nix/build.nix deleted file mode 100644 index 484049a421..0000000000 --- a/nix/build.nix +++ /dev/null @@ -1,321 +0,0 @@ -{ - lib, - stdenv, - - 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: - let - # note: under lazy-trees this introduces an extra copy - root = toString root' + "/"; - relPath = lib.removePrefix root path; - topLevelIncludes = [ - "crates" - "assets" - "extensions" - "script" - "tooling" - "Cargo.toml" - ".config" # nextest? - ".cargo" - ]; - firstComp = builtins.head (lib.path.subpath.components relPath); - in - builtins.elem firstComp topLevelIncludes; - - craneLib = crane.overrideToolchain rustToolchain; - gpu-lib = if withGLES then libglvnd else vulkan-loader; - commonArgs = - let - zedCargoLock = builtins.fromTOML (builtins.readFile ../crates/zed/Cargo.toml); - stdenv' = stdenv; - in - rec { - pname = "zed-editor"; - version = zedCargoLock.package.version + "-nightly"; - src = builtins.path { - path = ../.; - filter = mkIncludeFilter ../.; - name = "source"; - }; - - cargoLock = ../Cargo.lock; - - nativeBuildInputs = - [ - cmake - copyDesktopItems - curl - perl - pkg-config - protobuf - cargo-about - rustPlatform.bindgenHook - ] - ++ lib.optionals stdenv'.hostPlatform.isLinux [ makeWrapper ] - ++ lib.optionals stdenv'.hostPlatform.isDarwin [ - (cargo-bundle.overrideAttrs ( - new: old: { - version = "0.6.1-zed"; - src = fetchFromGitHub { - owner = "zed-industries"; - repo = "cargo-bundle"; - rev = "2be2669972dff3ddd4daf89a2cb29d2d06cad7c7"; - hash = "sha256-cSvW0ND148AGdIGWg/ku0yIacVgW+9f1Nsi+kAQxVrI="; - }; - cargoHash = "sha256-urn+A3yuw2uAO4HGmvQnKvWtHqvG9KHxNCCWTiytE4k="; - - # NOTE: can drop once upstream uses `finalAttrs` here: - # https://github.com/NixOS/nixpkgs/blob/10214747f5e6e7cb5b9bdf9e018a3c7b3032f5af/pkgs/build-support/rust/build-rust-package/default.nix#L104 - # - # See (for context): https://github.com/NixOS/nixpkgs/pull/382550 - cargoDeps = rustPlatform.fetchCargoVendor { - inherit (new) src; - hash = new.cargoHash; - patches = new.cargoPatches or []; - name = new.cargoDepsName or new.finalPackage.name; - }; - } - )) - ]; - - buildInputs = - [ - curl - fontconfig - freetype - # TODO: need staticlib of this for linking the musl remote server. - # should make it a separate derivation/flake output - # see https://crane.dev/examples/cross-musl.html - libgit2 - openssl - sqlite - zlib - zstd - ] - ++ lib.optionals stdenv'.hostPlatform.isLinux [ - alsa-lib - libxkbcommon - wayland - gpu-lib - xorg.libX11 - xorg.libxcb - ] - ++ lib.optionals stdenv'.hostPlatform.isDarwin [ - apple-sdk_15 - (darwinMinVersionHook "10.15") - ]; - - 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 { - fontDirectories = [ - ../assets/fonts/lilex - ../assets/fonts/ibm-plex-sans - ]; - }; - ZED_UPDATE_EXPLANATION = "Zed has been installed using Nix. Auto-updates have thus been disabled."; - RELEASE_VERSION = version; - LK_CUSTOM_WEBRTC = livekit-libwebrtc; - PROTOC="${protobuf}/bin/protoc"; - - CARGO_PROFILE = profile; - # need to handle some profiles specially https://github.com/rust-lang/cargo/issues/11053 - TARGET_DIR = "target/" + (if profile == "dev" then "debug" else profile); - - # 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 ${ - lib.makeLibraryPath [ - gpu-lib - wayland - ] - }"; - - NIX_OUTPATH_USED_AS_RANDOM_SEED = "norebuilds"; - }; - - # prevent nix from removing the "unused" wayland/gpu-lib rpaths - 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 - doCheck = false; - - cargoVendorDir = craneLib.vendorCargoDeps { - inherit src cargoLock; - 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 = - '' - 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: - if hasWebRtcSys crates then - drv.overrideAttrs (o: { - postPatch = (o.postPatch or "") + postPatch; - }) - else - drv; - }; - }; - cargoArtifacts = craneLib.buildDepsOnly commonArgs; -in -craneLib.buildPackage ( - lib.recursiveUpdate commonArgs { - inherit cargoArtifacts; - - dontUseCmakeConfigure = true; - - # without the env var generate-licenses fails due to crane's fetchCargoVendor, see: - # https://github.com/zed-industries/zed/issues/19971#issuecomment-2688455390 - # TODO: put this in a separate derivation that depends on src to avoid running it on every build - preBuild = '' - ALLOW_MISSING_LICENSES=yes bash script/generate-licenses - echo nightly > crates/zed/RELEASE_CHANNEL - ''; - - installPhase = - if stdenv.hostPlatform.isDarwin then - '' - runHook preInstall - - pushd crates/zed - sed -i "s/package.metadata.bundle-nightly/package.metadata.bundle/" Cargo.toml - export CARGO_BUNDLE_SKIP_BUILD=true - app_path="$(cargo bundle --profile $CARGO_PROFILE | xargs)" - popd - - mkdir -p $out/Applications $out/bin - # Zed expects git next to its own binary - ln -s ${git}/bin/git "$app_path/Contents/MacOS/git" - mv $TARGET_DIR/cli "$app_path/Contents/MacOS/cli" - mv "$app_path" $out/Applications/ - - # Physical location of the CLI must be inside the app bundle as this is used - # to determine which app to start - ln -s "$out/Applications/Zed Nightly.app/Contents/MacOS/cli" $out/bin/zed - - runHook postInstall - '' - else - '' - runHook preInstall - - mkdir -p $out/bin $out/libexec - cp $TARGET_DIR/zed $out/libexec/zed-editor - cp $TARGET_DIR/cli $out/bin/zed - ln -s $out/bin/zed $out/bin/zeditor # home-manager expects the CLI binary to be here - - - install -D "crates/zed/resources/app-icon-nightly@2x.png" \ - "$out/share/icons/hicolor/1024x1024@2x/apps/zed.png" - install -D crates/zed/resources/app-icon-nightly.png \ - $out/share/icons/hicolor/512x512/apps/zed.png - - # TODO: icons should probably be named "zed-nightly" - ( - export DO_STARTUP_NOTIFY="true" - export APP_CLI="zed" - export APP_ICON="zed" - export APP_NAME="Zed Nightly" - export APP_ARGS="%U" - mkdir -p "$out/share/applications" - ${lib.getExe envsubst} < "crates/zed/resources/zed.desktop.in" > "$out/share/applications/dev.zed.Zed-Nightly.desktop" - chmod +x "$out/share/applications/dev.zed.Zed-Nightly.desktop" - ) - - runHook postInstall - ''; - - # TODO: why isn't this also done on macOS? - postFixup = lib.optionalString stdenv.hostPlatform.isLinux '' - wrapProgram $out/libexec/zed-editor --suffix PATH : ${lib.makeBinPath [ nodejs_22 ]} - ''; - - meta = { - 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 = lib.licenses.gpl3Only; - mainProgram = "zed"; - platforms = lib.platforms.linux ++ lib.platforms.darwin; - }; - } -) diff --git a/nix/shell.nix b/nix/shell.nix deleted file mode 100644 index 6956de8e8a..0000000000 --- a/nix/shell.nix +++ /dev/null @@ -1,63 +0,0 @@ -{ - mkShell, - makeFontsConf, - pkgsCross, - - zed-editor, - - rust-analyzer, - rustup, - cargo-nextest, - cargo-hakari, - cargo-machete, - cargo-zigbuild, - nixfmt-rfc-style, - protobuf, - nodejs_22, - zig, -}: -(mkShell.override { inherit (zed-editor) stdenv; }) { - inputsFrom = [ zed-editor ]; - packages = [ - rust-analyzer - rustup - cargo-nextest - cargo-hakari - cargo-machete - cargo-zigbuild - nixfmt-rfc-style - # TODO: package protobuf-language-server for editing zed.proto - # TODO: add other tools used in our scripts - - # `build.nix` adds this to the `zed-editor` wrapper (see `postFixup`) - # we'll just put it on `$PATH`: - nodejs_22 - zig - ]; - - env = - let - baseEnvs = - (zed-editor.overrideAttrs (attrs: { - passthru = { inherit (attrs) env; }; - })).env; # exfil `env`; it's not in drvAttrs - in - (removeAttrs baseEnvs [ - "LK_CUSTOM_WEBRTC" # download the staticlib during the build as usual - "ZED_UPDATE_EXPLANATION" # allow auto-updates - "CARGO_PROFILE" # let you specify the profile - "TARGET_DIR" - ]) - // { - # note: different than `$FONTCONFIG_FILE` in `build.nix` – this refers to relative paths - # outside the nix store instead of to `$src` - FONTCONFIG_FILE = makeFontsConf { - fontDirectories = [ - "./assets/fonts/lilex" - "./assets/fonts/ibm-plex-sans" - ]; - }; - PROTOC = "${protobuf}/bin/protoc"; - ZED_ZSTD_MUSL_LIB = "${pkgsCross.musl64.pkgsStatic.zstd.out}/lib"; - }; -} diff --git a/shell.nix b/shell.nix deleted file mode 100644 index d1783071f9..0000000000 --- a/shell.nix +++ /dev/null @@ -1,11 +0,0 @@ -(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 = ./.; }).shellNix