From 757292856b5d3653926e52dd4da473b062b9a832 Mon Sep 17 00:00:00 2001 From: Vladimir Serov Date: Thu, 21 May 2020 21:30:56 +0300 Subject: editors/vscode: patchelf-ing without intermediate files --- editors/code/src/main.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'editors') diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 1c6e3093b..dbb241192 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -196,9 +196,7 @@ async function patchelf(dest: PathLike): Promise { title: "Patching rust-analysis for NixOS" }, async (progress, _) => { - const patchPath = path.join(os.tmpdir(), "patch-ra.nix"); - progress.report({ message: "Writing nix file", increment: 5 }); - await fs.writeFile(patchPath, ` + const expression = ` {src, pkgs ? import {}}: pkgs.stdenv.mkDerivation { name = "rust-analyzer"; @@ -210,12 +208,12 @@ async function patchelf(dest: PathLike): Promise { patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out ''; } - `); + `; const origFile = dest + "-orig"; await fs.rename(dest, origFile); progress.report({ message: "Patching executable", increment: 20 }); await new Promise((resolve, reject) => { - exec(`nix-build ${patchPath} --arg src '${origFile}' -o ${dest}`, + const handle = exec(`nix-build -E - --arg src '${origFile}' -o ${dest}`, (err, stdout, stderr) => { if (err != null) { reject(Error(stderr)); @@ -223,6 +221,8 @@ async function patchelf(dest: PathLike): Promise { resolve(stdout); } }); + handle.stdin?.write(expression); + handle.stdin?.end(); }); await fs.unlink(origFile); } -- cgit v1.2.3