about summary refs log tree commit diff
diff options
context:
space:
mode:
-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 191960960a3..4eaaed62bdc 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
     });
 
     // Patching executable if that's NixOS.
-    if (await fs.stat("/etc/nixos").then(_ => true).catch(_ => false)) {
+    if (await isNixOs()) {
         await patchelf(dest);
     }
 
@@ -348,6 +348,15 @@ async function getServer(config: Config, state: PersistentState): Promise<string
     return dest;
 }
 
+async function isNixOs(): Promise<boolean> {
+    try {
+        const contents = await fs.readFile("/etc/os-release");
+        return contents.indexOf("ID=nixos") !== -1;
+    } catch (e) {
+        return false;
+    }
+}
+
 async function downloadWithRetryDialog<T>(state: PersistentState, downloadFunc: () => Promise<T>): Promise<T> {
     while (true) {
         try {