mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
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 <me@cab404.ru>
This commit is contained in:
commit
5e85158706
1 changed files with 2 additions and 1 deletions
|
@ -269,7 +269,8 @@ function serverPath(config: Config): string | null {
|
||||||
async function isNixOs(): Promise<boolean> {
|
async function isNixOs(): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
const contents = (await vscode.workspace.fs.readFile(vscode.Uri.file("/etc/os-release"))).toString();
|
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 {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue