diff options
Diffstat (limited to 'editors')
-rw-r--r-- | editors/code/src/main.ts | 10 |
1 files changed, 5 insertions, 5 deletions
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<void> { | |||
196 | title: "Patching rust-analysis for NixOS" | 196 | title: "Patching rust-analysis 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 | } |