Commit 63ac0242 authored by Niklas Korz's avatar Niklas Korz
Browse files

zed-editor: refactor installPhase

parent 0b0ebca9
Loading
Loading
Loading
Loading
+59 −62
Original line number Diff line number Diff line
@@ -218,12 +218,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 +247,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

        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
    + lib.optionalString stdenv.hostPlatform.isLinux ''
      install -Dm755 $release_target/zed $out/libexec/zed-editor
      install -Dm755 $release_target/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 +273,8 @@ rustPlatform.buildRustPackage rec {
        mkdir -p "$out/share/applications"
        ${lib.getExe envsubst} < "crates/zed/resources/zed.desktop.in" > "$out/share/applications/dev.zed.Zed.desktop"
      )

    ''
    + ''
      runHook postInstall
    '';