-
Notifications
You must be signed in to change notification settings - Fork 623
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
Added snap packaging #3931
base: main
Are you sure you want to change the base?
Added snap packaging #3931
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do all of the shell completion files and vim/neovim files get exported? I don't see any logic related to them here.
I'd like to see a GitHub Actions workflow added, so this doesn't regress :).
case "$CRAFT_TARGET_ARCH" in | ||
amd64) arch=x86_64 ;; | ||
arm64) arch=aarch64 ;; | ||
*) arch="" ;; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumably it would be good to exit non-zero in this case with a good error message before curl tries to download something that doesn't exist.
snap/snapcraft.yaml
Outdated
- libgtk-4-dev | ||
- libadwaita-1-dev | ||
- git | ||
stage-packages: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too familiar with Snap. What are stage packages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stage-packages are ubuntu packages that satisfy runtime dependencies which get bundle in the snap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, why would we want to bundle shells? Do classic snaps not have access to the host binaries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does have access to anything on the host, so these could be removed.
8cc94d5
to
c5096fb
Compare
I've added a workflow to ensure the snap builds. I'll work on the shell completion. I hadn't done anything for that, but will |
039e0fb
to
8d06e3c
Compare
.github/workflows/snap.yaml
Outdated
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-24.04 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will probably want to use one of the project's runners. I'll let @mitchellh give a better review here.
snap/local/launcher
Outdated
#!/usr/bin/env bash | ||
|
||
export XDG_CONFIG_HOME="$SNAP_REAL_HOME/.config" | ||
export XDG_DATA_HOME="$SNAP_REAL_HOME/.local/share" | ||
|
||
exec "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we could just use /bin/sh
for the shebang.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@tristan957 I think I've responded to all the feedback so far. |
1aac9c2
to
f166cd7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not 100% sure I want to maintain a snap but it does seem to be more generally accepted. I'm going to think about that more.
My main request here is does snap/
have to be a top-level folder? I think it makes more sense to put into dist/
I think there is slight value in maintaining a flatpak and snap. They are "universal" formats that can run on any (if snap is supported) distro. It also gives us the ability to have an official Linux distribution channel(s) that we can recommend for people in the event downstreams can't properly package Ghostty for users. Of note, the author of this PR works at Canonical, so perhaps they could be interested in helping to maintain the Snap into the future :) |
Yeah. I'm leaning towards it. 😄 @kenvandine if you'd be happy to hang around and help out I'd absolutely love that too. |
snapcraft looks for the packaging in a few places. We'd have to jump through some hoops if we wanted it under dist. We could do it, but I would like to keep things as simple as possible for automated builds. I am happy to help look after the snap! I maintain quite a few already and I plan to be a daily user of ghostty too. Who registered the name in the snap store? |
Understood. We can keep it where it is.
Not me. We may have to register a dispute. |
Want me to go ahead and start the dispute? |
I created a name dispute request in the store. |
Appreciate it. After the dispute, do I need to transfer it to my account? |
Yeah, once we get everything in place we'll get it transferred. |
I've requested permission for classic confinement at https://forum.snapcraft.io/t/request-classic-confinement-for-ghostty/44523 |
f166cd7
to
4fadb87
Compare
I updated the builders to use Namespace, but it looks like there are issues there. I'll reach out to support for that. I tested this locally and works great, but will be important for CI to be able to run this. 😄 |
FYI Namespace has a fix in the pipeline so we'll probably have CI working soon. Probably within a week. |
snap/local/launcher
Outdated
export XDG_CONFIG_HOME="$SNAP_REAL_HOME/.config" | ||
export XDG_DATA_HOME="$SNAP_REAL_HOME/.local/share" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this supposed to work if XDG_CONFIG_HOME and XDG_DATA_HOME are defined to be elsewhere for a user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have a concern here in relation to users not using these paths for XDG_CONFIG_HOME or XDG_DATA_HOME. Like I said, could be me not understanding snap
ghostty: | ||
command: bin/ghostty | ||
command-chain: [ bin/launcher ] | ||
completer: share/bash-completion/completions/ghostty.bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about all the other completion scripts for other shells
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be fair, I don't much about snap, so take this comment with a grain of salt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the snap completer logic only knows bash for now.
Hi! I was about to request classic confinement for my own Ghostty snap when I noticed the request to approve the upstream one. Awesome! I'll stop working on my implementation, but you might find something useful in the GitHub Actions workflows I set up (link). They were designed to periodically check for new Ghostty releases and create snaps for both the stable and tip channels. However, all the version change detection would be redundant for workflows in this repository. |
Your Git history here is getting messed up, btw. You probably see it already but just in case you don't... |
Ugh, thanks I hadn't noticed. I've been rebasing while I iterate. Currently working to make sure the classic snap works well on non-ubuntu distros, which can be tedious. I'll get the history cleaned up soon. |
I'm struggling to see why the history is whacky. I've been rebasing my branch from main regularly and the number of files showing up in the PR as changed is growing. Since my rebases have been from main, those changes shouldn't show in my diff. I've never seen this happen before. Any pointers? |
I'll take a look and try to force push a fix onto the branch tomorrow if I can 😄 |
d98a199
to
c789c18
Compare
@kenvandine I cleaned up the git history. I'm not sure if I did a couple conflicts correctly so please review the files... but the conflicts were very small so I think they'd be minor. |
Thanks, that looks much better. There was one small change missing, I just pushed that as a new commit. I'll avoid rebasing for now to prevent that weirdness again. |
dependencies from the host
reliable across more distros as a classic snap.
distros and unset all SNAP environment variables that could leak at runtime
abc18d5
to
720dca4
Compare
Alright! Our CI seems to be hung up on this issue that our CI provider found: canonical/craft-providers#719 I'm not sure if there is a workaround we can apply to that yet but that's the major issue right now... |
This is my first time touching zig, check out my changes to src/termio/Exec.zig which should help ensure the snap isn't leaking environment variables that were necessary to launch ghostty but shouldn't be set in there resulting terminal shell. |
env.remove("DRIRC_CONFIGDIR"); | ||
env.remove("__EGL_EXTERNAL_PLATFORM_CONFIG_DIRS"); | ||
env.remove("__EGL_VENDOR_LIBRARY_DIRS"); | ||
env.remove("LD_LIBRARY_PATH"); | ||
env.remove("LIBGL_DRIVERS_PATH"); | ||
env.remove("LIBVA_DRIVERS_PATH"); | ||
env.remove("VK_LAYER_PATH"); | ||
env.remove("XLOCALEDIR"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would unconditionally remove these environment variables from the shell. Reading your launcher file above, you append the various snap paths if the environment variable exists. Wouldn't we just want to remove the snap paths from the environment variables if the user already had them set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the problem is the resulting shell in ghostty uses these library paths, drivers, etc for any processes started from ghostty which won't work mixing libs from in the container with host libs. This effectively drops everything needed to start ghostty without leaking those paths into the resulting shell. If a user is setting any of them in /etc or .bashrc, etc those will be honored by the shell anyway.
src/termio/Exec.zig
Outdated
@@ -732,6 +732,19 @@ const Subprocess = struct { | |||
try env.put("GHOSTTY_RESOURCES_DIR", dir); | |||
} | |||
|
|||
// Unset environment varies set by the snap | |||
if (env.get("SNAP") != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "Zig" way to do this is:
if (env.get("SNAP")) |_| {
…ck for environment variable.
Added snap packaging, fixes #3153
If whoever registered the name in the snap store could add me as a collaborator, I can handle getting it released in the store, setup automated builds, and request the necessary classic permissions in the store.