-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
ghostty: init at 1.0.0 #368404
base: master
Are you sure you want to change the base?
ghostty: init at 1.0.0 #368404
Conversation
Also needs to be reformatted w/ nixfmt-rfc-style (the nixpkgs-vet CI failure is a zig2nix bug that we can't really control) |
66c24b2
to
ace3254
Compare
downloadPage = "https://ghostty.org/download"; | ||
|
||
license = lib.licenses.mit; | ||
platforms = lib.platforms.linux; |
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.
platforms = lib.platforms.linux; | |
platforms = lib.platforms.linux ++ lib.platforms.darwin; |
If it doesn’t build on macOS, it would be better to set broken
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's less that it doesn't build on Darwin and more it can't build on Darwin since xcodebuild has to be invoked outside of the Nix build environment. I think we should just repackage the .dmg for now until we somehow figure out a way to compile it with Nix
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 curious why that’s the case
And whether that’s been tested since the darwin SDK refactor
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.
Ultimately neither I nor @jcollie have Darwin setups to test with, so either someone comes forward with a better idea, or we have to stick with a repackaging for now
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 don't think that anyone has tried since the darwin refactor. I won't be doing that work because I don't have a macOS machine to test on.
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.
Can confirm it builds. But I agree with @tymscar's suggestion to repackage the DMG. There's no need for extra work here.
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 don't think that anyone has tried since the darwin refactor. I won't be doing that work because I don't have a macOS machine to test on.
I could test, I willing be happy to help to support darwin. I have a m2 macbook which means I can cross compile.
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 believe discussions on this topic are happening on matrix https://matrix.to/#/#macos:nixos.org (though more focused on getting the build tooling chain working for source builds). I'm not sure where work to package the DMG is happening/being discussed.
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.
Long story short is that building the Mac app from source appears to be blocked on getting our Swift situation into a better place (if anyone has ideas on how to do a source build with our current Swift setup, please chime in in that matrix room).
I haven't seen anything about packaging the DMG.
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.
Bit of a drive by comment but: for my setup and https://github.com/kovidgoyal/kitty I eventually gave up and used the dmg directly; some features (like OS notifications) require signed executables
ace3254
to
df650f7
Compare
pkgs/by-name/gh/ghostty/package.nix
Outdated
patchelf --add-rpath "${lib.makeLibraryPath [ libX11 ]}" "$out/bin/.ghostty-wrapped" | ||
''; | ||
|
||
passthru.updateScript = nix-update-script { }; |
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 don't think nix-update handles zig2nix. We might need a bespoke update script for total automation
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 hoping to upstream the zig2nix generation once the dust settles on the 1.0 release, so this may be a moot issue soon.
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 is still an issue now though, and can easily lead to automatic PRs that aren't actually updated correctly. It should be removed until there's support for it
9da662e
to
ee671bc
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.
Just needs mister @ofborg to be happy
Any chance we can also get Ghostty's terminfo file added to the NixOS terminfo database, or does that belong in a separate PR? |
That should be handled already, there's a |
|
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.
Could you add this to nixos/tests/terminal-emulators.nix
and add the resulting test to passthru.tests
?
Would it be possible to include a patch so that ghostty runs without io_uring (which is disabled on linux-hardened)?
https://discord.com/channels/1005603569187160125/1312996817264181350 (sorry) No idea if this causes any visible performance issues |
That's the sort of thing that you can patch with |
The runtime closure includes all the zig sources:
Would be nice if we could get rid of those references. There seems to be a reference in the binary to Here is the fix, feel free to squash into your init commit: jcollie/nixpkgs@ghostty-init-1.0.0...fpletz:nixpkgs:pr/368404/remove-zig-src-refs |
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 may also be nice to pull glslang
, spriv-cross
, and simdutf
as well since we have them in Nixpkgs: https://github.com/ghostty-org/ghostty/blob/35b9ceee2116331b83c0c86269394e2545070b0f/build.zig#L271-L280
pkgs/by-name/gh/ghostty/package.nix
Outdated
patchelf --add-rpath "${lib.makeLibraryPath [ libX11 ]}" "$out/bin/.ghostty-wrapped" | ||
''; | ||
|
||
passthru.updateScript = nix-update-script { }; |
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 is still an issue now though, and can easily lead to automatic PRs that aren't actually updated correctly. It should be removed until there's support for it
ee671bc
to
6573bb3
Compare
I'm not prepared to make such large changes to the code in the package. That's something best taken upstream to get a proper build option to use the system version. |
Zig already has this option built in via its I'm also pretty sure this is intended for packagers, judging by the comment saying it's only not a default due to the lack of package availability in other distros/repos |
This review has been done with warden, please report any issues! Packages built
✅ ghostty
|
At this point, I'd like to get the current package merged. Once that's done we can refine things in follow-up commits. |
I also recommend leaving
|
I tried for a while to get this to work but was not able to. It may be my lack of understanding of what's needed here or possibly there's something upstream in Ghostty that needs to be fixed. In either case I don't want to hold up the package for this. I'll work on it in a subsequent patch. |
Are we in that much of a rush here? This is a quite a large, popular, and a bit complicated package. I think it'd be ok for us to take some time to clean things up a bit and make sure we land this in a good state -- it's only been 9 hours since this was originally submitted after all
Thanks for looking at all of this. I had only glanced at build.zig, and these dependencies seemed to be linked in the same way as all the others, so I figured it would be no different. Some of these are totally out of scope for this PR, but I think it'd be worth it to link with glslang -- which does seem to mostly work OOTB diff --git a/nixos/tests/terminal-emulators.nix b/nixos/tests/terminal-emulators.nix
index 1affcbf3c8f7..3fc820d3ac8b 100644
--- a/nixos/tests/terminal-emulators.nix
+++ b/nixos/tests/terminal-emulators.nix
@@ -44,6 +44,8 @@ let
germinal.pkg = p: p.germinal;
+ ghostty.pkg = p: p.ghostty;
+
gnome-terminal.pkg = p: p.gnome-terminal;
guake.pkg = p: p.guake;
diff --git a/pkgs/by-name/gh/ghostty/package.nix b/pkgs/by-name/gh/ghostty/package.nix
index 38bf66e654b2..aebd3f8e7293 100644
--- a/pkgs/by-name/gh/ghostty/package.nix
+++ b/pkgs/by-name/gh/ghostty/package.nix
@@ -7,10 +7,8 @@
fetchFromGitHub,
fontconfig,
freetype,
- git,
glib,
- gsettings-desktop-schemas,
- gtk4,
+ glslang,
harfbuzz,
libadwaita,
libGL,
@@ -20,7 +18,6 @@
libXi,
libXrandr,
ncurses,
- nix-update-script,
nixosTests,
oniguruma,
pandoc,
@@ -82,14 +79,21 @@ stdenv.mkDerivation (finalAttrs: {
# doCheck is set to false because unit tests currently fail inside the Nix sandbox.
doCheck = false;
doInstallCheck = true;
-
+
deps = callPackage ./deps.nix { name = "${finalAttrs.pname}-cache-${finalAttrs.version}"; };
- zigBuildFlags = [
- "--system"
- "${finalAttrs.deps}"
- "-Dversion-string=${finalAttrs.version}"
- ];
+ zigBuildFlags =
+ [
+ "--system"
+ "${finalAttrs.deps}"
+ "-Dversion-string=${finalAttrs.version}"
+ ]
+ # Some dependencies are vendored by default due to package availability issues in other repositories
+ # https://github.com/ghostty-org/ghostty/blob/35b9ceee2116331b83c0c86269394e2545070b0f/build.zig#L271-L280
+ # TODO: Use our spriv-cross & simdutf -@getchoo
+ ++ lib.mapAttrsToList (depName: package: "-fsys=${depName} --search-prefix ${lib.getLib package}") {
+ inherit glslang;
+ };
zigCheckFlags = finalAttrs.zigBuildFlags;
@@ -120,11 +124,17 @@ stdenv.mkDerivation (finalAttrs: {
NIX_LDFLAGS = [ "-lX11" ];
nativeInstallCheckInputs = [
- versionCheckHook
+ versionCheckHook
];
versionCheckProgramArg = [ "--version" ];
+ passthru = {
+ tests = lib.optionalAttrs stdenv.hostPlatform.isLinux {
+ nixos = nixosTests.terminal-emulators.ghostty;
+ };
+ };
+
meta = {
homepage = "https://ghostty.org/";
description = "Fast, native, feature-rich terminal emulator pushing modern features"; |
# Ghostty needs to be built with --release=fast, --release=debug and | ||
# --release=safe enable too many runtime safety checks. | ||
zig_hook = zig_0_13.hook.overrideAttrs { | ||
zig_default_flags = "-Dcpu=baseline -Doptimize=ReleaseFast --color off"; | ||
}; |
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 is a question for the community, not a request: Might it be worth having separate fast, debug, and safe packages, possibly with a release ? "fast" # or "debug", or "safe"
parameter? I guess the debug build might be useful for Ghostty users who want to file detailed bug reports, and from the docs (my emphasis), it looks like the safe build would appeal to some users:
-Doptimize=ReleaseFast
: Build with optimizations enabled and safety checks disabled. This is the recommended build mode for distribution. I'd prefer a safe build but terminal emulators are performance-sensitive and the safe build is currently too slow. I plan to improve this in the future. Other build modes are available:Debug
,ReleaseSafe
, andReleaseSmall
.
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 this would be something best left to a follow up PR that exposes more build options in general (like the rendering backend, font backend, etc.). I like it though ;)
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 debug builds are intended only for developers and are insanely slow (like, slower by a hundredfold, and there's a banner warning you that it's in debug mode and performance is going to be absolutely terrible).
The merit of offering a ReleaseSafe build is debatable but currently there's a lot of sanity checks in ReleaseSafe that also grind performance to a halt. Maybe we should disable some of them for ReleaseSafe, but that's a decision for later.
TL;DR ReleaseFast is the only option as of now that offers any reasonable performance.
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.
https://github.com/ghostty-org/ghostty/blob/main/nix/package.nix#L28-L39 is upstream. (possible follow up pr...)
Since this package is pretty hyped due to the private beta phase and the recent 1.0 public release, lots of people are eager to test this out. Just look at all those emoji reactions. 🚀 IMHO it makes sense to have an acceptable expression in unstable ASAP and fix minor issues later. |
Yep, this is already top 1 of open pull requests by counting 👍 and top 3 of all PRs ever created in nixpkgs. https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+sort%3Areactions-%2B1-desc+ |
If one is that eager to test it (like me 😉), just copy the two nix files to your own config and build the package yourself. 😁 Don't forget to do a |
zig_hook | ||
]; | ||
|
||
buildInputs = [ |
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 it will be nice when we have conditional buildInputs for Linux. It can be help for supporting MacOS
Adding Ghostty:
Ghostty is a terminal emulator that differentiates itself by being fast, feature-rich, and native. While there are many excellent terminal emulators available, they all force you to choose between speed, features, or native UIs. Ghostty provides all three.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.