-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
vscode-extensions.hashicorp.terraform: Init at 2.3.0 #110505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Please fix the typo in your commit. |
This is a semi-automatic executed nixpkgs-review which is checked by a human on a best effort basis and does not build all packages (e.g. lumo, tensorflow or pytorch). Result of 1 package built:
|
I tried this as well but the extension won't really run correctly if you just build it as an extension with no The syntax highlighting does work but the language features do not and you get an error every time you open VS Code. |
This is what I've tried till now, but still getting an error: hashicorp.terraform = ((vscode-utils.extensionFromVscodeMarketplace {
name = "terraform";
publisher = "hashicorp";
version = "2.3.0";
sha256 = "0696q8nr6kb5q08295zvbqwj7lr98z18gz1chf0adgrh476zm6qq";
}).overrideAttrs (oldAttrs: {
buildInputs = oldAttrs.buildInputs ++ [ pkgs.terraform-ls ];
meta = with lib; {
license = licenses.mit;
};
})); After going through the source of the extension, I think building from source and replacing these lines with |
@andyrichardson So had some time today and I figured it out. This is how I got it to work: hashicorp.terraform = callPackage ./hashicorp-terraform {}; default.nix { lib, fetchurl, vscode-utils, terraform-ls }:
vscode-utils.buildVscodeMarketplaceExtension rec {
mktplcRef = {
name = "terraform";
publisher = "hashicorp";
version = "2.4.0";
};
vsix = fetchurl {
name = "${mktplcRef.publisher}-${mktplcRef.name}.zip";
url = "https://github.com/hashicorp/vscode-terraform/releases/download/v${mktplcRef.version}/terraform-${mktplcRef.version}.vsix";
sha256 = "14waz0yv25f4l46y84px2g58qnawbzp1p24zrfjqlxmp99kx009n";
};
patches = [ ./fix-terraform-ls.patch ];
postPatch = ''
substituteInPlace out/extension.js --replace TERRAFORM-LS-PATH ${terraform-ls}/bin/terraform-ls
'';
meta = with lib; {
license = licenses.mit;
};
} fix-terraform-ls.patch diff --git a/out/extension.js b/out/extension.js
index 1de8aab..e2b3a3e 100644
--- a/out/extension.js
+++ b/out/extension.js
@@ -204,19 +204,7 @@ function pathToBinary() {
if (!_pathToBinaryPromise) {
let command = vscodeUtils_1.config('terraform').get('languageServer.pathToBinary');
if (!command) { // Skip install/upgrade if user has set custom binary path
- const installDir = `${extensionPath}/lsp`;
- const installer = new languageServerInstaller_1.LanguageServerInstaller();
- try {
- yield installer.install(installDir);
- }
- catch (err) {
- vscode.window.showErrorMessage(err);
- throw err;
- }
- finally {
- yield installer.cleanupZips(installDir);
- }
- command = `${installDir}/terraform-ls`;
+ command = 'TERRAFORM-LS-PATH';
}
_pathToBinaryPromise = Promise.resolve(command);
} |
@rhoriguchi thanks for helping out on this!
When users typically install the package to VSCode (without nix) it also doesn't install the language server, no? While the plugin can optionally integrate with a system-level language server, I'm unsure why it would be required as a build dependency? |
Because if it should work on multiple linux versions you can't easily install it for the package manager. One way around this is to vendor it which has its own problems.
This is a common thing to do in nixpkgs so that we have everything for it to run and you do not need to install something in your user environment. |
When you install the extension and you open a Here are some other extensions that also have the language server bundled: |
Ahh thanks for explaining - so the issue is that it tries to write to our immutable extension dir. That makes sense 👍 I was assuming the language server was external (similar to how TS works) |
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)