From 50f7632d8147b72085238da3c44a7ea206b42182 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Fri, 27 Dec 2024 16:26:25 +0100 Subject: [PATCH] Fix building with -Dflatpak=true While running a Ghostty instance built with this option currently crashes under Flatpak, at least it ensures we're able to build it again. --- build.zig | 6 +----- src/os/flatpak.zig | 3 ++- src/os/main.zig | 1 + src/os/passwd.zig | 5 +++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/build.zig b/build.zig index b1b992fe7..73a961b10 100644 --- a/build.zig +++ b/build.zig @@ -604,11 +604,7 @@ pub fn build(b: *std.Build) !void { // https://developer.gnome.org/documentation/guidelines/maintainer/integrating.html // Desktop file so that we have an icon and other metadata - if (config.flatpak) { - b.installFile("dist/linux/app-flatpak.desktop", "share/applications/com.mitchellh.ghostty.desktop"); - } else { - b.installFile("dist/linux/app.desktop", "share/applications/com.mitchellh.ghostty.desktop"); - } + b.installFile("dist/linux/app.desktop", "share/applications/com.mitchellh.ghostty.desktop"); // Right click menu action for Plasma desktop b.installFile("dist/linux/ghostty_dolphin.desktop", "share/kio/servicemenus/com.mitchellh.ghostty.desktop"); diff --git a/src/os/flatpak.zig b/src/os/flatpak.zig index f47437d35..faac4bd27 100644 --- a/src/os/flatpak.zig +++ b/src/os/flatpak.zig @@ -2,6 +2,7 @@ const std = @import("std"); const assert = std.debug.assert; const Allocator = std.mem.Allocator; const builtin = @import("builtin"); +const posix = std.posix; const log = std.log.scoped(.flatpak); @@ -26,7 +27,7 @@ pub fn isFlatpak() bool { /// /// Requires GIO, GLib to be available and linked. pub const FlatpakHostCommand = struct { - const fd_t = std.os.fd_t; + const fd_t = posix.fd_t; const EnvMap = std.process.EnvMap; const c = @cImport({ @cInclude("gio/gio.h"); diff --git a/src/os/main.zig b/src/os/main.zig index 40ac1d1d6..3b7007fcb 100644 --- a/src/os/main.zig +++ b/src/os/main.zig @@ -36,6 +36,7 @@ pub const fixMaxFiles = file.fixMaxFiles; pub const allocTmpDir = file.allocTmpDir; pub const freeTmpDir = file.freeTmpDir; pub const isFlatpak = flatpak.isFlatpak; +pub const FlatpakHostCommand = flatpak.FlatpakHostCommand; pub const home = homedir.home; pub const ensureLocale = locale.ensureLocale; pub const clickInterval = mouse.clickInterval; diff --git a/src/os/passwd.zig b/src/os/passwd.zig index f93d42f1b..54f84a15d 100644 --- a/src/os/passwd.zig +++ b/src/os/passwd.zig @@ -4,6 +4,7 @@ const internal_os = @import("main.zig"); const build_config = @import("../build_config.zig"); const Allocator = std.mem.Allocator; const ArenaAllocator = std.heap.ArenaAllocator; +const posix = std.posix; const log = std.log.scoped(.passwd); @@ -88,13 +89,13 @@ pub fn get(alloc: Allocator) !Entry { // Once started, we can close the child side. We do this after // wait right now but that is fine too. This lets us read the // parent and detect EOF. - _ = std.os.close(pty.slave); + _ = posix.close(pty.slave); // Read all of our output const output = output: { var output: std.ArrayListUnmanaged(u8) = .{}; while (true) { - const n = std.os.read(pty.master, &buf) catch |err| { + const n = posix.read(pty.master, &buf) catch |err| { switch (err) { // EIO is triggered at the end since we closed our // child side. This is just EOF for this. I'm not sure