1+ # !/SBUILD ver @v1.0.0
2+ # SELF: https://raw.githubusercontent.com/pkgforge/soarpkgs/main/packages/ghostty/nixappimage.nixpkgs.stable.yaml
3+ _disabled : true
4+ _disabled_reason :
5+ broken :
6+ - date : " 2025-01-14"
7+ reason : " Fails to create EGL Display" # https://github.com/NixOS/nixpkgs/issues/9415
8+
9+ pkg : " ghostty"
10+ pkg_id : " nixpkgs.ghostty"
11+ pkg_type : " nixappimage"
12+ app_id : " com.mitchellh.ghostty"
13+ category :
14+ - " TerminalEmulator"
15+ description : " Fast, native, feature-rich terminal emulator pushing modern features"
16+ desktop :
17+ url : " https://raw.githubusercontent.com/ghostty-org/ghostty/main/dist/linux/app.desktop"
18+ distro_pkg :
19+ archlinux :
20+ aur :
21+ - " ghostty-git"
22+ extra :
23+ - " ghostty"
24+ homebrew :
25+ - " ghostty"
26+ nixpkgs :
27+ - " ghostty"
28+ homepage :
29+ - " https://ghostty.org"
30+ - " https://github.com/ghostty-org/ghostty"
31+ icon :
32+ url : " https://raw.githubusercontent.com/ghostty-org/ghostty/main/images/icons/icon_256.png"
33+ license :
34+ - id : " MIT"
35+ url : " https://github.com/ghostty-org/ghostty/raw/918ccdba5cc65ccd1fb48a54c71306d869299441/LICENSE"
36+ maintainer :
37+ - " Azathothas (https://github.com/Azathothas)"
38+ note :
39+ - " [DO NOT RUN] (Meant for pkgforge CI Only)"
40+ - " Built Using Nixpkgs. Check/Report @ https://github.com/NixOS/nixpkgs"
41+ - " Packed Using NixAppImage. Check/Report @ https://github.com/pkgforge/nix-appimage"
42+ - " Learn more @ https://docs.pkgforge.dev/formats/packages/nixappimage"
43+ - " [PORTABLE] (Works on AnyLinux)"
44+ provides :
45+ - " ghostty"
46+ repology :
47+ - " ghostty"
48+ src_url :
49+ - " https://github.com/ghostty-org/ghostty"
50+ tag :
51+ - " terminal"
52+ x_exec :
53+ bsys : " host://nix"
54+ host :
55+ - " aarch64-Linux"
56+ - " x86_64-Linux"
57+ shell : " bash"
58+ pkgver : |
59+ nix derivation show "nixpkgs#ghostty" --impure --refresh --quiet 1>&1 2>/dev/null | sed -n '/^[[:space:]]*{/,$p' | jq -r '.. | objects | (select(has("version")).version, (select(has("env")) | select(.env.__json != null) | .env.__json | fromjson | select(has("version")).version) | select(.))' | tr -d '"'\''[:space:]'
60+ run : |
61+ #Build
62+ echo -e "\n" ; nix-instantiate --eval --expr "builtins.toJSON (with import <nixpkgs> {}; ${PKG}.meta)" --quiet 2>/dev/null | jq -r fromjson 2>/dev/null ; echo -e "\n"
63+ nix bundle --impure --bundler "github:pkgforge/nix-appimage?ref=main" "nixpkgs#ghostty" --cores "$(($(nproc)+1))" --max-jobs "$(($(nproc)+1))" --log-format bar-with-logs --out-link "${SBUILD_TMPDIR}/nixappimage"
64+ sudo rsync -achLv --no-relative "${SBUILD_TMPDIR}/nixappimage" "${SBUILD_TMPDIR}/${PKG}.nixappimage.tmp"
65+ sudo chown -R "$(whoami):$(whoami)" "${SBUILD_TMPDIR}" && chmod -R 755 "${SBUILD_TMPDIR}"
66+ chmod +x "${SBUILD_TMPDIR}/${PKG}.nixappimage.tmp"
67+ #Debloat & Fix things
68+ pushd "${SBUILD_TMPDIR}" &>/dev/null && \
69+ "./${PKG}.nixappimage.tmp" --appimage-extract >/dev/null && rm -rvf "./${PKG}.nixappimage.tmp"
70+ if [ ! -d "./squashfs-root" ] || [ "$(du -s "./squashfs-root" | cut -f1)" -le 100 ]; then
71+ echo -e "\n [X] FATAL: Building/Extraction probably Failed\n"
72+ exit 1
73+ fi
74+ #De-Nix
75+ pushd "${SBUILD_TMPDIR}" &>/dev/null || exit 1
76+ mkdir -pv "./squashfs-root/usr/share/applications" && mkdir -pv "./squashfs-root/usr/share/metainfo"
77+ ENTRYPOINT_DIR="$(readlink -f "./squashfs-root/entrypoint" | sed -E 's|^(/nix/store/[^/]+).*|\1|' | tr -d '[:space:]')"
78+ ENTRYPOINT_DIR="$(echo "${SBUILD_TMPDIR}/squashfs-root/${ENTRYPOINT_DIR}" | sed 's|//|/|g')" && export ENTRYPOINT_DIR="${ENTRYPOINT_DIR}"
79+ [ -d "${ENTRYPOINT_DIR}" ] && [[ "${ENTRYPOINT_DIR}" == "/tmp/"*"/nix/store/"* ]] || exit 1
80+ #Copy License
81+ [[ -s "${SBUILD_OUTDIR}/LICENSE" ]] || ( askalono --format "json" crawl --follow "${SBUILD_TMPDIR}/squashfs-root" | jq -r ".. | objects | .path? // empty" | head -n 1 | xargs -I "{}" cp -fv "{}" "${SBUILD_OUTDIR}/LICENSE" ) 2>/dev/null
82+ #Fix Symlinks
83+ rm -rvf "./squashfs-root/usr" 2>/dev/null
84+ find -L "./squashfs-root" -xtype f,l -name "*LC_MESSAGES*" -exec rm -rvf "{}" \;
85+ find -L "./squashfs-root" -xtype l | awk '{
86+ link=$0;
87+ cmd="readlink \""link"\"";
88+ cmd | getline target;
89+ close(cmd);
90+ cmd="readlink -f \""link"\" 2>/dev/null";
91+ if((cmd | getline resolved) <= 0 || system("test -e \""resolved"\"") != 0) {
92+ system("rm -rfv \""link"\" 2>/dev/null");
93+ } else {
94+ if(target == link || target == "."target ||
95+ index(resolved, link) > 0 || index(link, resolved) > 0 ||
96+ system("test \""resolved"\" -ef \"$(dirname \""link"\")\" || test \""resolved"\" -ef \"$(dirname $(dirname \""link"\"))\"") == 0) {
97+ system("rm -rfv \""link"\" 2>/dev/null");
98+ }
99+ }
100+ close(cmd);
101+ }'
102+ ln -sfn "$(realpath --relative-to="$(dirname "./squashfs-root/usr")" "${ENTRYPOINT_DIR}")" "./squashfs-root/usr"
103+ find "./squashfs-root" -maxdepth 1 -type l ! -name '*entrypoint*' -exec test -f "{}" \; -exec rsync -achvL --remove-source-files "{}" "{}.tmp" \; -exec mv "{}.tmp" "{}" \;
104+ #Icon
105+ if [[ ! -s "${SBUILD_OUTDIR}/${PKG}.png" && ! -s "${SBUILD_OUTDIR}/${PKG}.svg" ]]; then
106+ find -L "./squashfs-root/usr" -type f,l -regex '.*\.\(png\|svg\)' \
107+ -not -regex '.*\(favicon\|/\(16x16\|22x22\|24x24\|32x32\|36x36\|48x48\|64x64\|72x72\|96x96\)/\).*' \
108+ | awk '{print length, $0}' | sort -n | awk 'NR==1 {print $2}' | xargs -I "{}" cp -fv "{}" "./squashfs-root/${PKG}.png"
109+ if [[ ! -f "./squashfs-root/${PKG}.png" || $(stat -c%s "./squashfs-root/${PKG}.png") -le 3 ]]; then
110+ find -L "./squashfs-root/usr" -regex ".*\(128x128/apps\|256x256\)/.*${PKG}.*\.\(png\|svg\)" -printf "%s %p\n" -quit | sort -n | awk 'NR==1 {print $2}' | xargs -I "{}" cp -fv "{}" "./squashfs-root/${PKG}.png"
111+ fi
112+ cp -fv "./squashfs-root/${PKG}.png" "./squashfs-root/.DirIcon"
113+ else
114+ cp -fv "${SBUILD_OUTDIR}/${PKG}.png" "./squashfs-root/${PKG}.png" || cp -fv "${SBUILD_OUTDIR}/${PKG}.svg" "./squashfs-root/${PKG}.svg"
115+ cp "./squashfs-root/${PKG}.png" "./squashfs-root/.DirIcon" || cp "./squashfs-root/${PKG}.svg" "./squashfs-root/.DirIcon"
116+ fi
117+ #Desktop
118+ if [[ ! -s "${SBUILD_OUTDIR}/${PKG}.desktop" ]]; then
119+ find -L "./squashfs-root/usr" -name "*.desktop" -printf "%s %p\n" -quit | sort -n | awk 'NR==1 {print $2}' | xargs -I "{}" sh -c 'cp -fv "{}" "./squashfs-root/${PKG}.desktop"'
120+ else
121+ cp -fv "${SBUILD_OUTDIR}/${PKG}.desktop" "./squashfs-root/${PKG}.desktop"
122+ fi
123+ sed '/.*DBusActivatable.*/I d' -i "./squashfs-root/${PKG}.desktop"
124+ sed -E 's/\s+setup\s+/ /Ig' -i "./squashfs-root/${PKG}.desktop"
125+ sed "s/Icon=[^ ]*/Icon=${PKG}/" -i "./squashfs-root/${PKG}.desktop"
126+ #Perms
127+ find "./squashfs-root" -maxdepth 1 -type f -exec chmod "u=rx,go=rx" "{}" +
128+ #Purge Bloatware
129+ echo -e "\n[+] Purging Bloatware...\n"
130+ O_SIZE="$(du -sh "./squashfs-root" 2>/dev/null | awk '{print $1}' 2>/dev/null)" && export "O_SIZE=${O_SIZE}"
131+ #Locale/fonts/man
132+ find "./squashfs-root" -type d -regex '.*share/\(locale\(s\)?\|font\(s\)?\|man\).*' -print0 | xargs -0 -I "{}" sh -c 'rm -rvf "{}" 2>/dev/null && ln -s "/usr/share/locale" "{}" 2>/dev/null'
133+ mkdir -pv "./squashfs-root/usr/share"
134+ for dir in font fonts locale man; do
135+ rm -rvf "./squashfs-root/usr/share/${dir}" 2>/dev/null
136+ ln -sfv "/usr/share/${dir}" "./squashfs-root/usr/share/${dir}" 2>/dev/null
137+ done
138+ #Static Files
139+ find "./squashfs-root" -type f -regex ".*\.\(a\|cmake\|jmod\|gz\|md\|mk\|prf\|rar\|tar\|xz\|zip\)$" -print0 -exec sh -c 'rm -rvf "$1" 2>/dev/null' _ "{}" \;
140+ find "./squashfs-root" -type f -regex '.*\(LICENSE\|LICENSE\.md\|Makefile\)' -print0 -exec sh -c 'rm -rvf "$1" 2>/dev/null' _ "{}" \;
141+ #Static Dirs
142+ find "./squashfs-root" -type d -regex ".*\(doc/share\|/include\|/nix-support\|share/docs\|share/locale\|share/locales\|share/man\).*" ! -name "*${PKG%%-*}*" -print -exec rm -rvf "{}" + 2>/dev/null
143+ find "./squashfs-root" -type d -regex '.*/\(ensurepip\|example\|examples\|gcc\|i18n\|mkspecs\|__pycache__\|__pyinstaller\|test\|tests\|translation\|translations\|unit_test\|unit_tests\)' -print0 -exec sh -c 'rm -rvf "$1" 2>/dev/null' _ "{}" \;
144+ #llvm (need .so)
145+ find "./squashfs-root" -type d -name "*llvm*" -exec find "{}" -type f ! -name "*.so*" -delete \;
146+ #perl (need .so)
147+ find "./squashfs-root" -type d -name "*perl*" -exec find "{}" -type f ! -name "*.so*" -delete \;
148+ #systemd (need .so)
149+ find "./squashfs-root" -type d -name "*systemd*" -exec find "{}" -type f ! -name "*.so*" -delete \;
150+ P_SIZE="$(du -sh "./squashfs-root" 2>/dev/null | awk '{print $1}' 2>/dev/null)" && export "P_SIZE=${P_SIZE}"
151+ echo -e "\n[+] Shaved off ${O_SIZE} --> ${P_SIZE}\n"
152+ #Repack
153+ unset SOURCE_DATE_EPOCH
154+ cd "${SBUILD_OUTDIR}" && ARCH="$(uname -m)" appimagetool --comp "zstd" \
155+ --mksquashfs-opt -root-owned \
156+ --mksquashfs-opt -no-xattrs \
157+ --mksquashfs-opt -noappend \
158+ --mksquashfs-opt -b --mksquashfs-opt "1M" \
159+ --mksquashfs-opt -mkfs-time --mksquashfs-opt "0" \
160+ --mksquashfs-opt -Xcompression-level --mksquashfs-opt "22" \
161+ --no-appstream "${SBUILD_TMPDIR}/squashfs-root" "${SBUILD_OUTDIR}/${PKG}"
0 commit comments