nixos-vscode-server
nixos-vscode-server copied to clipboard
Feature: automatically symlink host extensions into server extensions
Since (the main?) use case for vscode-remote-ssh is to use (e.g. a more powerful) remote host from e.g. a mobile device with the same settings/env as on the remote host itself, it would be nice if this service would automatically symlink all extensions from ~/.vscode/extensions/* to ~/.vscode-server/extensions/.
Possibly as a default, but possibly optional (module argument?).
I can see an argument for having this as an option but by default it might be unexpected/not-desired? VSCode itself seems to make the distinction that extensions are installed "in Host" when viewing extensions while connected to a Remote workspace.
This feature possibly should also take into account the extensions installed via the vscode-with-extensions package. That package passes an extensions directory, e.g:
exec "/nix/store/<sha>-vscode-1.68.1/bin/code" --extensions-dir /nix/store/<sha>-vscode-extensions/share/vscode/extensions "$@"
The goal of this project is to make VS Code server work under NixOS, and I thus consider this out of scope. However I can see its use, and I can see how in order to make this feature work, it would require a lot of things already in place in this project. I am thinking of adding a few options that allow you to extend the functionality of my scripts. So you can add this linking yourself after patching has occured.
There is now a postPatch option that allows you to extend the project. Though what the issuer asked for can be done outside this project and could potentially be implemented with for example (untested):
{
pkgs,
config,
...
}: let
inherit (pkgs) buildEnv vscode-extensions vscode-utils writeTextFile;
vscodeExtensions = with vscode-extensions; [
bbenoist.nix
];
extensionJsonFile = writeTextFile {
name = "vscode-extensions-json";
destination = "/share/vscode/extensions/extensions.json";
text = vscode-utils.toExtensionJson vscodeExtensions;
};
combinedExtensionsDrv = buildEnv {
name = "vscode-extensions";
paths = vscodeExtensions ++ [ extensionJsonFile ];
};
in {
systemd.user.services.vscode-server-extensions = {
description = "VS Code extensions to make available for VS Code server";
serviceConfig.Type = "oneshot";
script = ''
ln -sfT ${combinedExtensionsDrv}/share/vscode/extensions ${config.services.vscode-server.installPath}/extensions
'';
wantedBy = [ "default.target" ];
};
}