From ce4b61003d8eb5383c4e759d919cdc72a137bc11 Mon Sep 17 00:00:00 2001 From: Vladimir Serov Date: Sun, 13 Mar 2022 00:26:36 +0300 Subject: [PATCH] editors/code: fix nixos detection Problem: NixOS started using quotes around it's id field in /etc/os-release Solution: Parially parsing os-release, and detecting, whether `nixos` appears anywhere in "ID=" field\ See https://github.com/rust-analyzer/rust-analyzer/issues/11695 Closes #11695 --- editors/code/src/main.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 3f9f0b3376..4856079f68 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -269,7 +269,8 @@ function serverPath(config: Config): string | null { async function isNixOs(): Promise { try { const contents = (await vscode.workspace.fs.readFile(vscode.Uri.file("/etc/os-release"))).toString(); - return contents.indexOf("ID=nixos") !== -1; + const idString = contents.split('\n').find((a) => a.startsWith("ID=")); + return idString?.toLowerCase()?.indexOf("nixos") !== -1; } catch { return false; }