summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 33240672af75e534771140a37a93230bc780936b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Maintainer: Hufflez <jackattacker518@gmail.com>
pkgname=t3code-git
_pkgname=t3code
pkgver=0.0.25.nightly.20260515.295.r1.g4f0f24f
pkgrel=1
pkgdesc='T3 Code desktop app (git version, built from source)'
arch=('x86_64')
url='https://t3.codes'
license=('MIT')
depends=(
  'alsa-lib'
  'at-spi2-core'
  'cairo'
  'dbus'
  'expat'
  'gdk-pixbuf2'
  'glib2'
  'gtk3'
  'hicolor-icon-theme'
  'libcups'
  'libdbusmenu-glib'
  'libdrm'
  'libx11'
  'libxcb'
  'libxcomposite'
  'libxdamage'
  'libxext'
  'libxfixes'
  'libxkbcommon'
  'libxrandr'
  'mesa'
  'nspr'
  'nss'
  'pango'
  'systemd-libs'
  'xdg-utils'
)
makedepends=(
  'git'
  'bun'
  'nodejs'
  'python'
)
optdepends=(
  'openai-codex: use the system-installed Codex CLI'
)
provides=("t3code=${pkgver}")
conflicts=('t3code' 't3code-bin')
options=('!debug' '!emptydirs' '!strip')
source=("${_pkgname}::git+https://github.com/pingdotgg/t3code.git")
sha256sums=('SKIP')

pkgver() {
  cd "$srcdir/$_pkgname"
  git describe --long --tags --abbrev=7 \
    | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
  # Example output: 0.0.13.r6.ga17a017
}

prepare() {
  cd "$srcdir/$_pkgname"
  bun install --frozen-lockfile
}

build() {
  cd "$srcdir/$_pkgname"
  bun run dist:desktop:linux

  local _appimage
  _appimage=$(find release/ -name '*.AppImage' -print -quit)
  if [[ -z "$_appimage" ]]; then
    echo "ERROR: No AppImage found in release/" >&2
    return 1
  fi

  chmod +x "$_appimage"
  "$_appimage" --appimage-extract
}

package() {
  cd "$srcdir/$_pkgname"

  # Install extracted AppImage to /opt (per Electron packaging guidelines for bundled apps)
  install -d "$pkgdir/opt/$pkgname"
  cp -a squashfs-root/. "$pkgdir/opt/$pkgname/"
  chmod -R a+rX "$pkgdir/opt/$pkgname"

  # Wrapper script (Wayland/X11 detection, Codex CLI integration)
  install -Dm755 /dev/stdin "$pkgdir/usr/bin/t3code" << 'EOF'
#!/usr/bin/env bash
set -euo pipefail

appdir='/opt/t3code-git'
export APPDIR="$appdir"

if [[ -z "${CODEX_CLI_PATH-}" ]] && command -v codex >/dev/null 2>&1; then
  export CODEX_CLI_PATH="$(command -v codex)"
fi

export PATH="$appdir:$PATH"

extra_flags=()
if [[ -n "${WAYLAND_DISPLAY-}" || "${XDG_SESSION_TYPE-}" == "wayland" ]]; then
  extra_flags+=(--enable-features=UseOzonePlatform --ozone-platform=wayland --ozone-platform-hint=wayland)
else
  extra_flags+=(--ozone-platform-hint=auto)
fi

exec "$appdir/t3code" --no-sandbox "${extra_flags[@]}" "$@"
EOF

  # Icon (from upstream source tree)
  install -Dm644 "assets/prod/black-universal-1024.png" \
    "$pkgdir/usr/share/icons/hicolor/1024x1024/apps/t3code.png"
  install -Dm644 "assets/prod/black-universal-1024.png" \
    "$pkgdir/usr/share/pixmaps/t3code.png"

  # Desktop entry (Icon= without extension per freedesktop spec)
  install -Dm644 /dev/stdin "$pkgdir/usr/share/applications/t3code.desktop" << 'EOF'
[Desktop Entry]
Name=T3 Code
Comment=T3 Code desktop application
Exec=t3code %U
Terminal=false
Type=Application
Icon=t3code
StartupWMClass=t3code
Categories=Development;
EOF

  # License
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}