aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
authorLaurenČ›iu Nicola <[email protected]>2020-12-21 17:18:50 +0000
committerLaurenČ›iu Nicola <[email protected]>2020-12-21 17:21:43 +0000
commitee734668308df4549eb2ddbd7fed7911dc3a7ba3 (patch)
tree5f9a50822a63802c873344012e5556105a0d7d16 /editors/code
parentc8a73fe655f7bf9778deeec4c8b4b541e0af398b (diff)
Use /etc/os-release to check for NixOS
The motivation in #5641 isn't too strong, but /etc/os-release exists on pretty much every Linux distro, while /etc/nixos sounds like an implementation detail.
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/src/main.ts11
1 files changed, 10 insertions, 1 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 191960960..4eaaed62b 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -340,7 +340,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string
340 }); 340 });
341 341
342 // Patching executable if that's NixOS. 342 // Patching executable if that's NixOS.
343 if (await fs.stat("/etc/nixos").then(_ => true).catch(_ => false)) { 343 if (await isNixOs()) {
344 await patchelf(dest); 344 await patchelf(dest);
345 } 345 }
346 346
@@ -348,6 +348,15 @@ async function getServer(config: Config, state: PersistentState): Promise<string
348 return dest; 348 return dest;
349} 349}
350 350
351async function isNixOs(): Promise<boolean> {
352 try {
353 const contents = await fs.readFile("/etc/os-release");
354 return contents.indexOf("ID=nixos") !== -1;
355 } catch (e) {
356 return false;
357 }
358}
359
351async function downloadWithRetryDialog<T>(state: PersistentState, downloadFunc: () => Promise<T>): Promise<T> { 360async function downloadWithRetryDialog<T>(state: PersistentState, downloadFunc: () => Promise<T>): Promise<T> {
352 while (true) { 361 while (true) {
353 try { 362 try {