os: add flatpak detection

This commit is contained in:
Mitchell Hashimoto
2023-02-25 21:20:48 -08:00
parent 64ef2dc051
commit 0a041957f1

9
src/os/flatpak.zig Normal file
View File

@ -0,0 +1,9 @@
const std = @import("std");
const builtin = @import("builtin");
/// Returns true if we're running in a Flatpak environment.
pub fn isFlatpak() bool {
// If we're not on Linux then we'll make this comptime false.
if (comptime builtin.os.tag != .linux) return false;
return if (std.fs.accessAbsolute("/.flatpak-info", .{})) true else |_| false;
}