Nix packages for third-party projects that don't ship their own flakes
0

Configure Feed

Select the types of activity you want to include in your feed.

agentic / packages / zed-preview / default.nix
3.5 kB 106 lines
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 autoPatchelfHook, 6 makeWrapper, 7 alsa-lib, 8 libGL, 9 libgcc, 10 vulkan-loader, 11 wayland, 12 xkeyboard-config, 13 versionCheckHook, 14}: 15 16stdenv.mkDerivation (finalAttrs: { 17 pname = "zed-preview"; 18 # Official preview channel tags are vX.Y.Z-pre (prerelease on GitHub). 19 version = "1.12.0-pre"; 20 21 src = fetchurl { 22 url = "https://github.com/zed-industries/zed/releases/download/v${finalAttrs.version}/zed-linux-x86_64.tar.gz"; 23 hash = "sha256-KqqXibrYxLzt+HInAJla86wbqgVlDE4PKLha6BOflgc="; 24 }; 25 26 sourceRoot = "zed-preview.app"; 27 28 nativeBuildInputs = [ 29 autoPatchelfHook 30 makeWrapper 31 ]; 32 33 buildInputs = [ 34 alsa-lib 35 libgcc 36 ]; 37 38 # Bundled $ORIGIN/../lib covers most deps; these are either NEEDED (alsa) or 39 # commonly dlopened at runtime (GPU / Wayland). 40 runtimeDependencies = [ 41 alsa-lib 42 libGL 43 vulkan-loader 44 wayland 45 ]; 46 47 installPhase = '' 48 runHook preInstall 49 50 mkdir -p $out 51 cp -a bin lib libexec share $out/ 52 # Coexist with nixpkgs zed-editor / zed-editor-fhs (bin + icons + libexec). 53 # CLI looks up ../libexec/zed-editor then ../lib/zed/zed-editor (see 54 # crates/cli); use the second path so profile install does not collide. 55 mv $out/bin/zed $out/bin/zed-preview 56 mkdir -p $out/lib/zed 57 mv $out/libexec/zed-editor $out/lib/zed/zed-editor 58 rmdir $out/libexec 59 60 # Rename icons so share/icons/.../zed.png does not collide with zed-editor. 61 find $out/share/icons -type f -name 'zed.png' | while read -r icon; do 62 mv "$icon" "$(dirname "$icon")/zed-preview.png" 63 done 64 65 # Point the desktop entry at our binary + icon names (line-anchored; plain 66 # substitute would also rewrite TryExec when matching Exec=zed). 67 sed -i \ 68 -e 's/^TryExec=zed$/TryExec=zed-preview/' \ 69 -e 's/^Exec=zed/Exec=zed-preview/' \ 70 -e 's/^Icon=zed$/Icon=zed-preview/' \ 71 $out/share/applications/dev.zed.Zed-Preview.desktop 72 73 runHook postInstall 74 ''; 75 76 postFixup = '' 77 # xkbcommon defaults to /usr/share/X11/xkb, which does not exist on NixOS. 78 wrapProgram $out/bin/zed-preview \ 79 --set ZED_UPDATE_EXPLANATION "Zed Preview has been installed using Nix. Auto-updates have thus been disabled." \ 80 --set XKB_CONFIG_ROOT "${xkeyboard-config}/share/X11/xkb" 81 # GUI binary (CLI spawns this via ../lib/zed/zed-editor). 82 wrapProgram $out/lib/zed/zed-editor \ 83 --set ZED_UPDATE_EXPLANATION "Zed Preview has been installed using Nix. Auto-updates have thus been disabled." \ 84 --set XKB_CONFIG_ROOT "${xkeyboard-config}/share/X11/xkb" 85 ''; 86 87 nativeInstallCheckInputs = [ versionCheckHook ]; 88 versionCheckProgram = "${placeholder "out"}/bin/zed-preview"; 89 versionCheckProgramArg = "--version"; 90 # Upstream prints "Zed preview 1.12.0 <sha> …" (no -pre suffix). 91 preInstallCheck = '' 92 export version="${lib.removeSuffix "-pre" finalAttrs.version}" 93 ''; 94 doInstallCheck = true; 95 96 meta = { 97 description = "High-performance, multiplayer code editor (official Linux preview binaries)"; 98 homepage = "https://zed.dev"; 99 changelog = "https://github.com/zed-industries/zed/releases/tag/v${finalAttrs.version}"; 100 # AGPL for the editor; some bundled components differ — see licenses.md in the tarball. 101 license = lib.licenses.gpl3Only; 102 mainProgram = "zed-preview"; 103 platforms = [ "x86_64-linux" ]; 104 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; 105 }; 106})