aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/main.ts12
1 files changed, 6 insertions, 6 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index bfa9980be..ad3c1a192 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -196,9 +196,7 @@ async function patchelf(dest: PathLike): Promise<void> {
196 title: "Patching rust-analyzer for NixOS" 196 title: "Patching rust-analyzer for NixOS"
197 }, 197 },
198 async (progress, _) => { 198 async (progress, _) => {
199 const patchPath = path.join(os.tmpdir(), "patch-ra.nix"); 199 const expression = `
200 progress.report({ message: "Writing nix file", increment: 5 });
201 await fs.writeFile(patchPath, `
202 {src, pkgs ? import <nixpkgs> {}}: 200 {src, pkgs ? import <nixpkgs> {}}:
203 pkgs.stdenv.mkDerivation { 201 pkgs.stdenv.mkDerivation {
204 name = "rust-analyzer"; 202 name = "rust-analyzer";
@@ -210,12 +208,12 @@ async function patchelf(dest: PathLike): Promise<void> {
210 patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out 208 patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out
211 ''; 209 '';
212 } 210 }
213 `); 211 `;
214 const origFile = dest + "-orig"; 212 const origFile = dest + "-orig";
215 await fs.rename(dest, origFile); 213 await fs.rename(dest, origFile);
216 progress.report({ message: "Patching executable", increment: 20 }); 214 progress.report({ message: "Patching executable", increment: 20 });
217 await new Promise((resolve, reject) => { 215 await new Promise((resolve, reject) => {
218 exec(`nix-build ${patchPath} --arg src '${origFile}' -o ${dest}`, 216 const handle = exec(`nix-build -E - --arg src '${origFile}' -o ${dest}`,
219 (err, stdout, stderr) => { 217 (err, stdout, stderr) => {
220 if (err != null) { 218 if (err != null) {
221 reject(Error(stderr)); 219 reject(Error(stderr));
@@ -223,6 +221,8 @@ async function patchelf(dest: PathLike): Promise<void> {
223 resolve(stdout); 221 resolve(stdout);
224 } 222 }
225 }); 223 });
224 handle.stdin?.write(expression);
225 handle.stdin?.end();
226 }); 226 });
227 await fs.unlink(origFile); 227 await fs.unlink(origFile);
228 } 228 }
@@ -280,7 +280,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string
280 await download(artifact.browser_download_url, dest, "Downloading rust-analyzer server", { mode: 0o755 }); 280 await download(artifact.browser_download_url, dest, "Downloading rust-analyzer server", { mode: 0o755 });
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 (await fs.stat("/etc/nixos").then(_ => true).catch(_ => false)) {
284 await patchelf(dest); 284 await patchelf(dest);
285 } 285 }
286 286