Zed: Difference between revisions

Pxp9 (talk | contribs)
Usage instructions for nixpkgs remote server
Line 27: Line 27:
   }
   }
  }
  }
</syntaxhighlight>
== Remote Server ==
When connecting to a remote server running NixOS, Zed will automatically upload its own static server binary and connect to it:
:<syntaxhighlight lang="console">
➜  ~ ls .zed_server
zed-remote-server-stable-0.169.2
➜  ~ file .zed_server/zed-remote-server-stable-0.169.2
.zed_server/zed-remote-server-stable-0.169.2: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, BuildID[sha1]=b1ac2c83127e7a9a072840cd7c24d7d125c1b655, not stripped
➜  ~ ldd .zed_server/zed-remote-server-stable-0.169.2
statically linked
</syntaxhighlight>
While this static binary works fine on NixOS, you may want to consider using the nixpkgs provided server instead if you have custom patches to apply or mistrust whatever binary upstream Zed is downloading to your server.
The binary name of the <code>remote_server</code> output of the <code>zed-editor</code> package matches what Zed expects on the remote, meaning you can symlink <code>"${pkgs.zed-editor.remote_server}/bin"</code> to <code>~/.zed_server</code> on the remote host to make use of it. As an end user, you have to ensure the remote uses the same version of the zed-editor package as the local client.
In home-manager, this can be used as follows:
:<syntaxhighlight lang="nix">
{ pkgs, ... }:
{
  home.file.".zed_server".source = "${pkgs.zed-editor.remote_server}/bin";
}
</syntaxhighlight>
If the version does not match, Zed will try to upload the binary itself (as the existing remote binary has a version-specific name), and in this particular example fail to do so because we symlinked `.zed_server` to a read-only directory in the Nix store.
Alternatively, you may choose to only symlink the binary and not the directory, so Zed will successfully fall back to its own binary upload if the remote package version does not match:
:<syntaxhighlight lang="nix">
{ pkgs, ... }:
let
  inherit (pkgs.zed-editor) version remote_server;
  binary_name = "zed-remote-server-stable-${version}"
in
{
  home.file.".zed_server/${binary_name}".source = "${remote_server}/bin/${binary_name}";
}
</syntaxhighlight>
</syntaxhighlight>