diff options
-rw-r--r-- | editors/code/src/main.ts | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 0a2c30594..1c6e3093b 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -192,13 +192,13 @@ async function bootstrapServer(config: Config, state: PersistentState): Promise< | |||
192 | async function patchelf(dest: PathLike): Promise<void> { | 192 | async function patchelf(dest: PathLike): Promise<void> { |
193 | await vscode.window.withProgress( | 193 | await vscode.window.withProgress( |
194 | { | 194 | { |
195 | location: vscode.ProgressLocation.Notification, | 195 | location: vscode.ProgressLocation.Notification, |
196 | title: "Patching rust-analysis for NixOS" | 196 | title: "Patching rust-analysis for NixOS" |
197 | }, | 197 | }, |
198 | async (progress, _) => { | 198 | async (progress, _) => { |
199 | let patch_path = path.join(os.tmpdir(), "patch-ra.nix") | 199 | const patchPath = path.join(os.tmpdir(), "patch-ra.nix"); |
200 | progress.report({message: "Writing nix file", increment: 5}) | 200 | progress.report({ message: "Writing nix file", increment: 5 }); |
201 | await fs.writeFile(patch_path, ` | 201 | await fs.writeFile(patchPath, ` |
202 | {src, pkgs ? import <nixpkgs> {}}: | 202 | {src, pkgs ? import <nixpkgs> {}}: |
203 | pkgs.stdenv.mkDerivation { | 203 | pkgs.stdenv.mkDerivation { |
204 | name = "rust-analyzer"; | 204 | name = "rust-analyzer"; |
@@ -210,23 +210,23 @@ async function patchelf(dest: PathLike): Promise<void> { | |||
210 | patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out | 210 | patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out |
211 | ''; | 211 | ''; |
212 | } | 212 | } |
213 | `) | 213 | `); |
214 | let orig_file = dest + "-orig" | 214 | const origFile = dest + "-orig"; |
215 | await fs.rename(dest, orig_file) | 215 | await fs.rename(dest, origFile); |
216 | progress.report({message: "Patching executable", increment: 20}) | 216 | progress.report({ message: "Patching executable", increment: 20 }); |
217 | await new Promise((resolve, reject) => { | 217 | await new Promise((resolve, reject) => { |
218 | exec(`nix-build ${patch_path} --arg src '${orig_file}' -o ${dest}`, | 218 | exec(`nix-build ${patchPath} --arg src '${origFile}' -o ${dest}`, |
219 | (err, stdout, stderr) => { | 219 | (err, stdout, stderr) => { |
220 | if (err != null) { | 220 | if (err != null) { |
221 | reject(Error(stderr)) | 221 | reject(Error(stderr)); |
222 | } else { | 222 | } else { |
223 | resolve(stdout) | 223 | resolve(stdout); |
224 | } | 224 | } |
225 | }) | 225 | }); |
226 | }) | 226 | }); |
227 | await fs.unlink(orig_file) | 227 | await fs.unlink(origFile); |
228 | } | 228 | } |
229 | ) | 229 | ); |
230 | } | 230 | } |
231 | 231 | ||
232 | async function getServer(config: Config, state: PersistentState): Promise<string | undefined> { | 232 | async function getServer(config: Config, state: PersistentState): Promise<string | undefined> { |
@@ -281,7 +281,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string | |||
281 | 281 | ||
282 | // Patching executable if that's NixOS. | 282 | // Patching executable if that's NixOS. |
283 | if (fs.stat("/etc/nixos").then(_ => true).catch(_ => false)) { | 283 | if (fs.stat("/etc/nixos").then(_ => true).catch(_ => false)) { |
284 | await patchelf(dest) | 284 | await patchelf(dest); |
285 | } | 285 | } |
286 | 286 | ||
287 | await state.updateServerVersion(config.package.version); | 287 | await state.updateServerVersion(config.package.version); |