diff --git a/pkgs/misc/vscode-extensions/default.nix b/pkgs/misc/vscode-extensions/default.nix index 60048e16192d..8c8e646964d7 100644 --- a/pkgs/misc/vscode-extensions/default.nix +++ b/pkgs/misc/vscode-extensions/default.nix @@ -357,6 +357,8 @@ let }; }; + hashicorp.terraform = callPackage ./terraform {}; + hookyqr.beautify = buildVscodeMarketplaceExtension { mktplcRef = { name = "beautify"; diff --git a/pkgs/misc/vscode-extensions/terraform/default.nix b/pkgs/misc/vscode-extensions/terraform/default.nix new file mode 100644 index 000000000000..16a3c7477cdc --- /dev/null +++ b/pkgs/misc/vscode-extensions/terraform/default.nix @@ -0,0 +1,25 @@ +{ lib, fetchurl, vscode-utils, terraform-ls }: +vscode-utils.buildVscodeMarketplaceExtension rec { + mktplcRef = { + name = "terraform"; + publisher = "hashicorp"; + version = "2.6.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 = "1zg90x2asl6gakd2w8fn4imllqgrzdb1dn3728s63blmml42a1xp"; + }; + + 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; + maintainers = with maintainers; [ rhoriguchi ]; + }; +} diff --git a/pkgs/misc/vscode-extensions/terraform/fix-terraform-ls.patch b/pkgs/misc/vscode-extensions/terraform/fix-terraform-ls.patch new file mode 100644 index 000000000000..84a626b17deb --- /dev/null +++ b/pkgs/misc/vscode-extensions/terraform/fix-terraform-ls.patch @@ -0,0 +1,25 @@ +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); + }