Skip to content

Commit e4f922a

Browse files
bors[bot]lnicola
andauthored
Merge #6985
6985: Use /etc/os-release to check for NixOS r=matklad a=lnicola Closes #5641 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. Co-authored-by: Laurențiu Nicola <[email protected]>
2 parents 8776287 + ee73466 commit e4f922a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

editors/code/src/main.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,23 @@ async function getServer(config: Config, state: PersistentState): Promise<string
340340
});
341341

342342
// Patching executable if that's NixOS.
343-
if (await fs.stat("/etc/nixos").then(_ => true).catch(_ => false)) {
343+
if (await isNixOs()) {
344344
await patchelf(dest);
345345
}
346346

347347
await state.updateServerVersion(config.package.version);
348348
return dest;
349349
}
350350

351+
async function isNixOs(): Promise<boolean> {
352+
try {
353+
const contents = await fs.readFile("/etc/os-release");
354+
return contents.indexOf("ID=nixos") !== -1;
355+
} catch (e) {
356+
return false;
357+
}
358+
}
359+
351360
async function downloadWithRetryDialog<T>(state: PersistentState, downloadFunc: () => Promise<T>): Promise<T> {
352361
while (true) {
353362
try {

0 commit comments

Comments
 (0)