Skip to content

Commit 5e85158

Browse files
bors[bot]cab404
andauthored
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 #11695 Closes #11695 Co-authored-by: Vladimir Serov <[email protected]>
2 parents 5fcf979 + ce4b610 commit 5e85158

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)