From 1b4f2a48168b3d90e11365552d1e7e601a4be6b6 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Fri, 17 Jan 2025 16:40:11 +0100 Subject: [PATCH] zed-editor: add installRemoteServer option --- modules/programs/zed-editor.nix | 24 +++++++++++++++++++ tests/modules/programs/zed-editor/default.nix | 1 + .../zed-editor/install-remote-server.nix | 20 ++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 tests/modules/programs/zed-editor/install-remote-server.nix diff --git a/modules/programs/zed-editor.nix b/modules/programs/zed-editor.nix index 80039a8ca..cfc55c073 100644 --- a/modules/programs/zed-editor.nix +++ b/modules/programs/zed-editor.nix @@ -80,6 +80,21 @@ 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 = false; + example = true; + 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 the + ["Remote Server" section](https://wiki.nixos.org/wiki/Zed#Remote_Server) + in the wiki. + ''; + }; }; }; @@ -101,6 +116,15 @@ in { else [ cfg.package ]; + home.file = mkIf (cfg.installRemoteServer && (cfg.package ? remote_server)) + (let + inherit (cfg.package) version remote_server; + binaryName = "zed-remote-server-stable-${version}"; + in { + ".zed_server/${binaryName}".source = + lib.getExe' remote_server binaryName; + }); + xdg.configFile."zed/settings.json" = (mkIf (mergedSettings != { }) { source = jsonFormat.generate "zed-user-settings" mergedSettings; }); diff --git a/tests/modules/programs/zed-editor/default.nix b/tests/modules/programs/zed-editor/default.nix index 3c5c894fe..2fcd8da2c 100644 --- a/tests/modules/programs/zed-editor/default.nix +++ b/tests/modules/programs/zed-editor/default.nix @@ -1,5 +1,6 @@ { zed-extensions = ./extensions.nix; + zed-install-remote-server = ./install-remote-server.nix; zed-keymap = ./keymap.nix; zed-settings = ./settings.nix; } diff --git a/tests/modules/programs/zed-editor/install-remote-server.nix b/tests/modules/programs/zed-editor/install-remote-server.nix new file mode 100644 index 000000000..fdfbc095f --- /dev/null +++ b/tests/modules/programs/zed-editor/install-remote-server.nix @@ -0,0 +1,20 @@ +{ config, ... }: + +{ + programs.zed-editor = { + enable = true; + package = config.lib.test.mkStubPackage { version = "57"; } // { + remote_server = config.lib.test.mkStubPackage { + buildScript = '' + mkdir -p $out/bin + touch $out/bin/zed-remote-server-stable-57 + ''; + }; + }; + installRemoteServer = true; + }; + + nmt.script = '' + assertFileExists "home-files/.zed_server/zed-remote-server-stable-57" + ''; +}