Unnamed repository; edit this file 'description' to name the repository.
Merge #11696
11696: editors/code: fix nixos detection r=lnicola a=cab404 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 Co-authored-by: Vladimir Serov <[email protected]>
bors[bot] 2022-03-13
parent 5fcf979 · parent ce4b610 · commit 5e85158
-rw-r--r--editors/code/src/main.ts3
1 files changed, 2 insertions, 1 deletions
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<boolean> {
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;
}