Skip to content

Commit 40c05a5

Browse files
committed
ghostty-bin: init at 1.1.3
1 parent 8fcc714 commit 40c05a5

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{
2+
lib,
3+
stdenvNoCC,
4+
_7zz,
5+
fetchurl,
6+
makeBinaryWrapper,
7+
}:
8+
9+
stdenvNoCC.mkDerivation (finalAttrs: {
10+
pname = "ghostty-bin";
11+
version = "1.1.3";
12+
13+
src = fetchurl {
14+
url = "https://release.files.ghostty.org/${finalAttrs.version}/Ghostty.dmg";
15+
hash = "sha256-ZOUUGI9UlZjxZtbctvjfKfMz6VTigXKikB6piKFPJkc=";
16+
};
17+
18+
sourceRoot = ".";
19+
20+
nativeBuildInputs = [
21+
_7zz
22+
makeBinaryWrapper
23+
];
24+
25+
postInstall = ''
26+
mkdir -p $out/Applications
27+
mv Ghostty.app $out/Applications/
28+
makeWrapper $out/Applications/Ghostty.app/Contents/MacOS/ghostty $out/bin/ghostty
29+
'';
30+
31+
/**
32+
Ghostty really likes all of it's resources to be in the same directory, so link them back after we split them
33+
34+
- https://github.com/ghostty-org/ghostty/blob/4b4d4062dfed7b37424c7210d1230242c709e990/src/os/resourcesdir.zig#L11-L52
35+
- https://github.com/ghostty-org/ghostty/blob/4b4d4062dfed7b37424c7210d1230242c709e990/src/termio/Exec.zig#L745-L750
36+
- https://github.com/ghostty-org/ghostty/blob/4b4d4062dfed7b37424c7210d1230242c709e990/src/termio/Exec.zig#L818-L834
37+
38+
terminfo and shell integration should also be installable on remote machines
39+
40+
```nix
41+
{ pkgs, ... }: {
42+
environment.systemPackages = [ pkgs.ghostty.terminfo ];
43+
44+
programs.bash = {
45+
interactiveShellInit = ''
46+
if [[ "$TERM" == "xterm-ghostty" ]]; then
47+
builtin source ${pkgs.ghostty.shell_integration}/bash/ghostty.bash
48+
fi
49+
'';
50+
};
51+
}
52+
```
53+
54+
On linux we can move the original files and make symlinks to them
55+
but on darwin (when using the .app bundle) we need to copy the files
56+
in order to maintain signed integrity
57+
*/
58+
resourceDir = "${placeholder "out"}/Applications/Ghostty.app/Contents/Resources";
59+
postFixup = ''
60+
mkdir -p $terminfo/share
61+
cp -r $resourceDir/terminfo $terminfo/share/terminfo
62+
63+
cp -r $resourceDir/ghostty/shell-integration $shell_integration
64+
65+
cp -r $resourceDir/vim/vimfiles $vim
66+
'';
67+
68+
# Usually the multiple-outputs hook would take care of this, but
69+
# our manpages are in the .app bundle
70+
preFixup = ''
71+
mkdir -p $man/share
72+
cp -r $resourceDir/man $man/share/man
73+
'';
74+
75+
outputs = [
76+
"out"
77+
"man"
78+
"shell_integration"
79+
"terminfo"
80+
"vim"
81+
];
82+
83+
meta = {
84+
description = "Fast, native, feature-rich terminal emulator pushing modern features";
85+
longDescription = ''
86+
Ghostty is a terminal emulator that differentiates itself by being
87+
fast, feature-rich, and native. While there are many excellent terminal
88+
emulators available, they all force you to choose between speed,
89+
features, or native UIs. Ghostty provides all three.
90+
'';
91+
homepage = "https://ghostty.org/";
92+
downloadPage = "https://ghostty.org/download";
93+
changelog = "https://ghostty.org/docs/install/release-notes/${
94+
builtins.replaceStrings [ "." ] [ "-" ] finalAttrs.version
95+
}";
96+
license = lib.licenses.mit;
97+
maintainers = with lib.maintainers; [ Enzime ];
98+
mainProgram = "ghostty";
99+
outputsToInstall = [
100+
"out"
101+
"man"
102+
"shell_integration"
103+
"terminfo"
104+
];
105+
platforms = lib.platforms.darwin;
106+
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
107+
};
108+
})

0 commit comments

Comments
 (0)