Unverified Commit 7027221a authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

zed-editor: add remote_server (#370017)

parents 4fb742d7 b4c31cf7
Loading
Loading
Loading
Loading
+73 −63
Original line number Diff line number Diff line
@@ -39,8 +39,10 @@
  libX11,
  libXext,
  livekit-libwebrtc,
  testers,

  withGLES ? false,
  buildRemoteServer ? true,
}:

assert withGLES -> stdenv.hostPlatform.isLinux;
@@ -95,6 +97,8 @@ rustPlatform.buildRustPackage rec {
  pname = "zed-editor";
  version = "0.169.2";

  outputs = [ "out" ] ++ lib.optional buildRemoteServer "remote_server";

  src = fetchFromGitHub {
    owner = "zed-industries";
    repo = "zed";
@@ -168,7 +172,7 @@ rustPlatform.buildRustPackage rec {
  cargoBuildFlags = [
    "--package=zed"
    "--package=cli"
  ];
  ] ++ lib.optional buildRemoteServer "--package=remote_server";

  # Required on darwin because we don't have access to the
  # proprietary Metal shader compiler.
@@ -218,12 +222,14 @@ rustPlatform.buildRustPackage rec {
    ];

  installPhase =
    if stdenv.hostPlatform.isDarwin then
    ''
      runHook preInstall

      release_target="target/${stdenv.hostPlatform.rust.cargoShortTarget}/release"
    ''
    + lib.optionalString stdenv.hostPlatform.isDarwin ''
      # cargo-bundle expects the binary in target/release
        mv target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/zed target/release/zed
      mv $release_target/zed target/release/zed

      pushd crates/zed

@@ -245,26 +251,20 @@ rustPlatform.buildRustPackage rec {

      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/${stdenv.hostPlatform.rust.cargoShortTarget}/release/cli $app_path/Contents/MacOS/cli
      ln -s ${lib.getExe git} $app_path/Contents/MacOS/git
      mv $release_target/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.app/Contents/MacOS/cli $out/bin/zeditor

        runHook postInstall
      ''
    else
    ''
        runHook preInstall
    + lib.optionalString stdenv.hostPlatform.isLinux ''
      install -Dm755 $release_target/zed $out/libexec/zed-editor
      install -Dm755 $release_target/cli $out/bin/zeditor

        mkdir -p $out/bin $out/libexec
        cp target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/zed $out/libexec/zed-editor
        cp target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/cli $out/bin/zeditor

        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
      install -Dm644 ${src}/crates/zed/resources/app-icon@2x.png $out/share/icons/hicolor/1024x1024@2x/apps/zed.png
      install -Dm644 ${src}/crates/zed/resources/app-icon.png $out/share/icons/hicolor/512x512/apps/zed.png

      # 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)
@@ -277,7 +277,11 @@ rustPlatform.buildRustPackage rec {
        mkdir -p "$out/share/applications"
        ${lib.getExe envsubst} < "crates/zed/resources/zed.desktop.in" > "$out/share/applications/dev.zed.Zed.desktop"
      )

    ''
    + lib.optionalString buildRemoteServer ''
      install -Dm755 $release_target/remote_server $remote_server/bin/zed-remote-server-stable-$version
    ''
    + ''
      runHook postInstall
    '';

@@ -305,6 +309,12 @@ rustPlatform.buildRustPackage rec {
    };
    fhs = fhs { };
    fhsWithPackages = f: fhs { additionalPkgs = f; };
    tests = {
      remoteServerVersion = testers.testVersion {
        package = zed-editor.remote_server;
        command = "zed-remote-server-stable-${version} version";
      };
    };
  };

  meta = {