Skip to content

core, gtk: implement host resources dir for Flatpak #6661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2025

Conversation

alaviss
Copy link
Contributor

@alaviss alaviss commented Mar 10, 2025

Introduces host resources directory as a new concept: A directory containing application resources that can only be accessed from the host operating system. This is significant for sandboxed application runtimes like Flatpak where shells spawned on the host should have access to application resources to enable integrations.

Alongside this, apprt is now allowed to override the resources lookup logic.

@alaviss alaviss force-pushed the push-qrqtympzwnox branch from 4d88103 to 53e5efc Compare March 10, 2025 21:44
@alaviss alaviss force-pushed the push-qrqtympzwnox branch from 53e5efc to f76d334 Compare March 11, 2025 01:49
@alaviss alaviss changed the title os: add resources lookup for Flatpak flatpak, termio: use host paths for resources Mar 11, 2025
@alaviss
Copy link
Contributor Author

alaviss commented Mar 11, 2025

Changes in v2:

  • New FlatpakInfo struct that provides methods for querying information about the current Flatpak.
  • Only resolve host paths for termio.Exec instead of everything. This fixes issues with themes as Ghostty cannot access the host paths directly and must use /app paths.

@alaviss alaviss force-pushed the push-qrqtympzwnox branch from f76d334 to 4982c0d Compare March 11, 2025 23:19
@alaviss alaviss changed the title flatpak, termio: use host paths for resources core, gtk: implement host resources dir for Flatpak Mar 11, 2025
@alaviss
Copy link
Contributor Author

alaviss commented Mar 11, 2025

Changes in v3:

  • Dropped FlatpakInfo as it is not very useful outside of the host resources directory case.
  • GlobalState will now resolve *resources_dir with apprt.runtime implementation if available.
  • Added a new parameter to resourcesDir to request for a host-accessible resource directory if available.
  • Added host_resources_dir to GlobalState. I'm not entirely sure whether this is the best way, but it's certainly the cleanest to me.
  • Removed additional logic in termio.Exec.

@alaviss alaviss force-pushed the push-qrqtympzwnox branch 4 times, most recently from e1e708a to 9aa7f5d Compare March 15, 2025 07:25
@alaviss
Copy link
Contributor Author

alaviss commented Mar 15, 2025

Changes in v4:

@alaviss alaviss marked this pull request as ready for review March 15, 2025 07:28
@alaviss alaviss requested review from a team as code owners March 15, 2025 07:28
Copy link
Contributor

@mitchellh mitchellh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its better, but I still don't love this approach...

Calling resourcesDir twice once for guest once for host is not great, especially since 99% of users (today, but a significant number) are not running in a sandboxed mode. Its just waste.

A perhaps better approach would be to return a struct instead so we can get all the info in one call. But stepping back its not clear to me if we ever need both, would it be more useful to redocument resourcesDir as always being host accessible?

@alaviss
Copy link
Contributor Author

alaviss commented Mar 15, 2025

But stepping back its not clear to me if we ever need both

For platforms like Flatpak the host-accessible directory is usually non-accessible in the sandbox, but the sandbox path is not accessible outside.

We need sandbox-accessible paths for things like reading bundled themes, and only termio needs the host-accessible one since that's where host processes are launched. So on Flatpak you'd want both to implement all the features.

@alaviss alaviss force-pushed the push-qrqtympzwnox branch from 9aa7f5d to de54443 Compare March 15, 2025 20:15
@alaviss
Copy link
Contributor Author

alaviss commented Mar 15, 2025

Changes in v5:

  • Rebased to main
  • New ResourcesDir struct that abstracts over host/app paths selection, removing the need to allocate two paths for non-sandboxed cases, as well as reducing the resourcesDir call count to 1.

Copy link
Member

@pluiedev pluiedev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic looks sound, just one small nitpick

@alaviss alaviss force-pushed the push-qrqtympzwnox branch from 696d3b2 to 255aa59 Compare May 15, 2025 18:55
@alaviss alaviss requested a review from a team as a code owner May 15, 2025 18:55
Copy link
Member

@pluiedev pluiedev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better. Thanks!

@pluiedev pluiedev requested a review from mitchellh May 18, 2025 21:37
@pluiedev pluiedev requested a review from jcollie May 18, 2025 21:37
@pluiedev
Copy link
Member

pluiedev commented Jun 2, 2025

IMO there isn't much that's blocking this PR right now and I'd like to get this merged for the Flatpak build to become more usable, but as this is a core change I would have to hear from someone else first. @mitchellh @jcollie you both have previously requested changes - any thoughts at the moment?

@alaviss alaviss force-pushed the push-qrqtympzwnox branch from 255aa59 to f54cce3 Compare June 23, 2025 20:15
@alaviss
Copy link
Contributor Author

alaviss commented Jun 23, 2025

Rebased to solve merge conflicts.

Copy link
Member

@jcollie jcollie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have time to re-review right now but I'll trust @pluiedev 's judgement.

Copy link
Member

@tristan957 tristan957 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty solid. I'll also leave it to Leah.

Copy link
Contributor

@mitchellh mitchellh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a couple reallyyyyy small things that would be good and quick to address.

I'm going to approve this so that we can merge once they're addressed and I don't block anyone.

alaviss added 2 commits June 24, 2025 07:35
Introduces host resources directory as a new concept: A directory
containing application resources that can only be accessed from the host
operating system. This is significant for sandboxed application runtimes
like Flatpak where shells spawned on the host should have access to
application resources to enable integrations.

Alongside this, apprt is now allowed to override the resources lookup
logic.
@mitchellh mitchellh force-pushed the push-qrqtympzwnox branch from f54cce3 to faf9d59 Compare June 24, 2025 11:36
@mitchellh
Copy link
Contributor

Actually I just quickly addressed them myself. CI running now, auto merge on!

@mitchellh mitchellh enabled auto-merge June 24, 2025 11:36
@mitchellh mitchellh merged commit 5f6cdb0 into ghostty-org:main Jun 24, 2025
38 checks passed
@github-actions github-actions bot added this to the 1.2.0 milestone Jun 24, 2025
@alaviss alaviss deleted the push-qrqtympzwnox branch June 24, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants