Skip to content

Commit

Permalink
zed-editor: add installRemoteServer option
Browse files Browse the repository at this point in the history
  • Loading branch information
GaetanLepage committed Jan 24, 2025
1 parent 7b9ece1 commit 28f8854
Showing 1 changed file with 39 additions and 16 deletions.
55 changes: 39 additions & 16 deletions modules/programs/zed-editor.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,49 @@ in {
Use the name of a repository in the [extension list](https://github.com/zed-industries/extensions/tree/main/extensions).
'';
};

installRemoteServer = mkOption {
type = types.bool;
default = true;
example = false;
description = ''
Whether to symlink the Zed's remote server binary to the expected location.
This allows remotely connecting to this system from a distant Zed client.
For more information, consult [this section of the wiki](https://wiki.nixos.org/wiki/Zed#Remote_Server).
'';
};
};
};

config = mkIf cfg.enable {
home.packages = if cfg.extraPackages != [ ] then
[
(pkgs.symlinkJoin {
name =
"${lib.getName cfg.package}-wrapped-${lib.getVersion cfg.package}";
paths = [ cfg.package ];
preferLocalBuild = true;
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/zeditor \
--suffix PATH : ${lib.makeBinPath cfg.extraPackages}
'';
})
]
else
[ cfg.package ];
home = {
packages = if cfg.extraPackages != [ ] then
[
(pkgs.symlinkJoin {
name = "${lib.getName cfg.package}-wrapped-${
lib.getVersion cfg.package
}";
paths = [ cfg.package ];
preferLocalBuild = true;
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/zeditor \
--suffix PATH : ${lib.makeBinPath cfg.extraPackages}
'';
})
]
else
[ cfg.package ];

file = lib.optionalAttrs cfg.installRemoteServer (let
inherit (cfg.package) version remote_server;
binary_name = "zed-remote-server-stable-${version}";
in {
".zed_server/${binary_name}".source =
lib.getExe' remote_server binary_name;
});
};

xdg.configFile."zed/settings.json" = (mkIf (mergedSettings != { }) {
source = jsonFormat.generate "zed-user-settings" mergedSettings;
Expand Down

0 comments on commit 28f8854

Please sign in to comment.