diff options
| author | Laurențiu Nicola <lnicola@dend.ro> | 2020-12-21 19:18:50 +0200 |
|---|---|---|
| committer | Laurențiu Nicola <lnicola@dend.ro> | 2020-12-21 19:21:43 +0200 |
| commit | ee734668308df4549eb2ddbd7fed7911dc3a7ba3 (patch) | |
| tree | 5f9a50822a63802c873344012e5556105a0d7d16 | |
| parent | c8a73fe655f7bf9778deeec4c8b4b541e0af398b (diff) | |
| download | rust-ee734668308df4549eb2ddbd7fed7911dc3a7ba3.tar.gz rust-ee734668308df4549eb2ddbd7fed7911dc3a7ba3.zip | |
Use /etc/os-release to check for NixOS
The motivation in #5641 isn't too strong, but /etc/os-release exists on pretty much every Linux distro, while /etc/nixos sounds like an implementation detail.
| -rw-r--r-- | editors/code/src/main.ts | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 191960960a3..4eaaed62bdc 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -340,7 +340,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string }); // Patching executable if that's NixOS. - if (await fs.stat("/etc/nixos").then(_ => true).catch(_ => false)) { + if (await isNixOs()) { await patchelf(dest); } @@ -348,6 +348,15 @@ async function getServer(config: Config, state: PersistentState): Promise<string return dest; } +async function isNixOs(): Promise<boolean> { + try { + const contents = await fs.readFile("/etc/os-release"); + return contents.indexOf("ID=nixos") !== -1; + } catch (e) { + return false; + } +} + async function downloadWithRetryDialog<T>(state: PersistentState, downloadFunc: () => Promise<T>): Promise<T> { while (true) { try { |
