From 4d8d8c385e78f5f744e2e2f81f5c56fade6ca4eb Mon Sep 17 00:00:00 2001 From: Ingo Reitz <9l@9lo.re> Date: Sun, 24 Nov 2024 21:15:57 +0100 Subject: [PATCH] zed-editor: add extraPackages option Add extraPackages option to make for example language servers available to Zed without having to add them to `home.packages` or similar. --- modules/programs/zed-editor.nix | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/programs/zed-editor.nix b/modules/programs/zed-editor.nix index 250d891bb..a9baebf90 100644 --- a/modules/programs/zed-editor.nix +++ b/modules/programs/zed-editor.nix @@ -22,6 +22,13 @@ in { package = mkPackageOption pkgs "zed-editor" { }; + extraPackages = mkOption { + type = with types; listOf package; + default = [ ]; + example = literalExpression "[ pkgs.nixd ]"; + description = "Extra packages available to Zed."; + }; + userSettings = mkOption { type = jsonFormat.type; default = { }; @@ -76,7 +83,22 @@ in { }; config = mkIf cfg.enable { - home.packages = [ 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 ]; xdg.configFile."zed/settings.json" = (mkIf (mergedSettings != { }) { source = jsonFormat.generate "zed-user-settings" mergedSettings;