Skip to content

Commit ce4b610

Browse files
committed
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 #11695 Closes #11695
1 parent 5fcf979 commit ce4b610

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

editors/code/src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ function serverPath(config: Config): string | null {
269269
async function isNixOs(): Promise<boolean> {
270270
try {
271271
const contents = (await vscode.workspace.fs.readFile(vscode.Uri.file("/etc/os-release"))).toString();
272-
return contents.indexOf("ID=nixos") !== -1;
272+
const idString = contents.split('\n').find((a) => a.startsWith("ID="));
273+
return idString?.toLowerCase()?.indexOf("nixos") !== -1;
273274
} catch {
274275
return false;
275276
}

0 commit comments

Comments
 (0)