Skip to content

Commit

Permalink
zed-editor: add extraPackages option
Browse files Browse the repository at this point in the history
Add extraPackages option to make for example language servers
available to Zed without having to add them to `home.packages` or
similar.
  • Loading branch information
ninelore authored Nov 24, 2024
1 parent 83002f1 commit 4d8d8c3
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion modules/programs/zed-editor.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = { };
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4d8d8c3

Please sign in to comment.