-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3c47bb
commit ea17767
Showing
1 changed file
with
155 additions
and
0 deletions.
There are no files selected for viewing
155 changes: 155 additions & 0 deletions
155
packages/telegram-desktop/nixappimage.nixpkgs.stable.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
#!/SBUILD ver @v1.0.0 | ||
#SELF: https://raw.githubusercontent.com/pkgforge/soarpkgs/refs/heads/main/packages/telegram-desktop/nixappimage.nixpkgs.stable.yaml | ||
_disabled: false | ||
|
||
pkg: "telegram-desktop" | ||
pkg_id: "nixpkgs.telegram-desktop" | ||
pkg_type: "nixappimage" | ||
app_id: "org.telegram.desktop" | ||
build_util: | ||
- "curl#bin" | ||
- "jq#bin" | ||
category: | ||
- "Chat" | ||
- "IRCClient" | ||
description: "Official desktop version of Telegram messaging app" | ||
desktop: | ||
url: "https://raw.githubusercontent.com/telegramdesktop/tdesktop/refs/heads/dev/lib/xdg/org.telegram.desktop.desktop" | ||
distro_pkg: | ||
alpine: | ||
- "telegram-desktop" | ||
archlinux: | ||
aur: | ||
- "telegram-desktop-bin" | ||
- "telegram-desktop-dev" | ||
- "telegram-desktop-dev-bin" | ||
- "telegram-desktop-git" | ||
extra: | ||
- "telegram-desktop" | ||
debian: | ||
- "telegram-desktop" | ||
gnuguix: | ||
- "telegram-desktop" | ||
homebrew: | ||
- "telegram-desktop" | ||
- "telegram-desktop@beta" | ||
nixpkgs: | ||
- "tdesktop" | ||
- "telegram-desktop" | ||
homepage: | ||
- "https://desktop.telegram.org" | ||
- "https://github.com/telegramdesktop/tdesktop" | ||
icon: | ||
url: "https://raw.githubusercontent.com/telegramdesktop/tdesktop/refs/heads/dev/Telegram/Telegram/Images.xcassets/Icon.iconset/icon_512x512.png" | ||
license: | ||
- id: "GPL-3.0" | ||
url: "https://github.com/telegramdesktop/tdesktop/raw/48fb0f3b1e3921b7ddd5bd4b7bb0e30875c91583/LICENSE" | ||
maintainer: | ||
- "Azathothas (https://github.com/Azathothas)" | ||
note: | ||
- "[DO NOT RUN] (Meant for pkgforge CI Only)" | ||
- "Built Using Nixpkgs. Check/Report @ https://github.com/NixOS/nixpkgs" | ||
- "Packed Using NixAppImage. Check/Report @ https://github.com/pkgforge/nix-appimage" | ||
- "Learn more @ https://docs.pkgforge.dev/formats/packages/nixappimage" | ||
- "[PORTABLE] (Works on AnyLinux)" | ||
provides: | ||
- "telegram-desktop==Telegram-Desktop" | ||
repology: | ||
- "telegram-desktop" | ||
src_url: | ||
- "https://github.com/telegramdesktop/tdesktop" | ||
tag: | ||
- "chat" | ||
- "Communications" | ||
- "Networking/Chat" | ||
x_exec: | ||
host: | ||
- "aarch64-Linux" | ||
- "x86_64-Linux" | ||
shell: "bash" | ||
pkgver: | | ||
nix derivation show "nixpkgs#telegram-desktop" --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:]' | ||
run: | | ||
#Build | ||
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" | ||
nix bundle --impure --bundler "github:pkgforge/nix-appimage?ref=main" "nixpkgs#telegram-desktop" --cores "$(($(nproc)+1))" --max-jobs "$(($(nproc)+1))" --log-format bar-with-logs --out-link "${SBUILD_TMPDIR}/nixappimage" | ||
sudo rsync -achLv --no-relative "${SBUILD_TMPDIR}/nixappimage" "${SBUILD_TMPDIR}/${PKG}.nixappimage.tmp" | ||
sudo chown -Rv "$(whoami):$(whoami)" "${SBUILD_TMPDIR}" && chmod -Rv 755 "${SBUILD_TMPDIR}" | ||
chmod -v +x "${SBUILD_TMPDIR}/${PKG}.nixappimage.tmp" | ||
#Debloat & Fix things | ||
pushd "${SBUILD_TMPDIR}" >/dev/null 2>&1 && \ | ||
"./${PKG}.nixappimage.tmp" --appimage-extract >/dev/null && rm -rf "./${PKG}.nixappimage.tmp" | ||
if [ ! -d "./squashfs-root" ] || [ "$(du -s "./squashfs-root" | cut -f1)" -le 100 ]; then | ||
echo -e "\n [X] FATAL: Building/Extraction probably Failed\n" | ||
exit 1 | ||
fi | ||
#De-Nix | ||
pushd "${SBUILD_TMPDIR}" >/dev/null 2>&1 || exit 1 | ||
mkdir -pv "./squashfs-root/usr/share/applications" && mkdir -pv "./squashfs-root/usr/share/metainfo" | ||
ENTRYPOINT_DIR="$(readlink -f "./squashfs-root/entrypoint" | sed -E 's|^(/nix/store/[^/]+).*|\1|' | tr -d '[:space:]')" | ||
ENTRYPOINT_DIR="$(echo "${SBUILD_TMPDIR}/squashfs-root/${ENTRYPOINT_DIR}" | sed 's|//|/|g')" && export ENTRYPOINT_DIR="${ENTRYPOINT_DIR}" | ||
[ -d "${ENTRYPOINT_DIR}" ] && [[ "${ENTRYPOINT_DIR}" == "/tmp/"*"/nix/store/"* ]] || exit 1 | ||
#Copy License | ||
[[ -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 | ||
#Fix Symlinks | ||
rm -rf "./squashfs-root/usr" 2>/dev/null | ||
ln -sfn "$(realpath --relative-to="$(dirname "./squashfs-root/usr")" "${ENTRYPOINT_DIR}")" "./squashfs-root/usr" | ||
find "./squashfs-root" -maxdepth 1 -type l ! -name '*entrypoint*' -exec test -f "{}" \; -exec rsync -achvL --remove-source-files "{}" "{}.tmp" \; -exec mv "{}.tmp" "{}" \; | ||
#Icon | ||
if [[ ! -s "${SBUILD_OUTDIR}/${PKG}.png" && ! -s "${SBUILD_OUTDIR}/${PKG}.svg" ]]; then | ||
find -L "./squashfs-root/usr" -type f,l -regex '.*\.\(png\|svg\)' \ | ||
-not -regex '.*\(favicon\|/\(16x16\|22x22\|24x24\|32x32\|36x36\|48x48\|64x64\|72x72\|96x96\)/\).*' \ | ||
| awk '{print length, $0}' | sort -n | awk 'NR==1 {print $2}' | xargs -I "{}" cp -fv "{}" "./squashfs-root/${PKG}.png" | ||
if [[ ! -f "./squashfs-root/${PKG}.png" || $(stat -c%s "./squashfs-root/${PKG}.png") -le 3 ]]; then | ||
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" | ||
fi | ||
cp -fv "./squashfs-root/${PKG}.png" "./squashfs-root/.DirIcon" | ||
else | ||
cp -fv "${SBUILD_OUTDIR}/${PKG}.png" "./squashfs-root/${PKG}.png" || cp -fv "${SBUILD_OUTDIR}/${PKG}.svg" "./squashfs-root/${PKG}.svg" | ||
cp "./squashfs-root/${PKG}.png" "./squashfs-root/.DirIcon" || cp "./squashfs-root/${PKG}.svg" "./squashfs-root/.DirIcon" | ||
fi | ||
#Desktop | ||
if [[ ! -s "${SBUILD_OUTDIR}/${PKG}.desktop" ]]; then | ||
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"' | ||
else | ||
cp -fv "${SBUILD_OUTDIR}/${PKG}.desktop" "./squashfs-root/${PKG}.desktop" | ||
fi | ||
sed '/.*DBusActivatable.*/I d' -i "./squashfs-root/${PKG}.desktop" | ||
sed -E 's/\s+setup\s+/ /Ig' -i "./squashfs-root/${PKG}.desktop" | ||
sed "s/Icon=[^ ]*/Icon=${PKG}/" -i "./squashfs-root/${PKG}.desktop" | ||
#Perms | ||
find "./squashfs-root" -maxdepth 1 -type f -exec chmod "u=rx,go=rx" "{}" + | ||
#Purge Bloatware | ||
echo -e "\n[+] Purging Bloatware...\n" | ||
O_SIZE="$(du -sh "./squashfs-root" 2>/dev/null | awk '{print $1}' 2>/dev/null)" && export "O_SIZE=${O_SIZE}" | ||
#Locale/fonts/man | ||
find "./squashfs-root" -type d -regex '.*share/\(locale\(s\)?\|font\(s\)?\|man\).*' -print0 | xargs -0 -I "{}" sh -c 'rm -rf "{}" 2>/dev/null && ln -s "/usr/share/locale" "{}" 2>/dev/null' | ||
mkdir -pv "./squashfs-root/usr/share" | ||
for dir in font fonts locale man; do | ||
rm -rf "./squashfs-root/usr/share/${dir}" 2>/dev/null | ||
ln -sfv "/usr/share/${dir}" "./squashfs-root/usr/share/${dir}" 2>/dev/null | ||
done | ||
#Static Files | ||
find "./squashfs-root" -type f -regex ".*\.\(a\|cmake\|jmod\|gz\|md\|mk\|prf\|rar\|tar\|xz\|zip\)$" -print0 -exec sh -c 'rm -rf "$1" 2>/dev/null' _ "{}" \; | ||
find "./squashfs-root" -type f -regex '.*\(LICENSE\|LICENSE\.md\|Makefile\)' -print0 -exec sh -c 'rm -rf "$1" 2>/dev/null' _ "{}" \; | ||
#Static Dirs | ||
find "./squashfs-root" -type d -regex ".*\(doc/share\|/include\|/nix-support\|share/docs\|share/locale\|share/locales\|share/man\).*" ! -name "*${PKG%%-*}*" -print -exec rm -rf "{}" + 2>/dev/null | ||
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 -rf "$1" 2>/dev/null' _ "{}" \; | ||
#llvm (need .so) | ||
find "./squashfs-root" -type d -name "*llvm*" -exec find "{}" -type f ! -name "*.so*" -delete \; | ||
#perl (need .so) | ||
find "./squashfs-root" -type d -name "*perl*" -exec find "{}" -type f ! -name "*.so*" -delete \; | ||
#systemd (need .so) | ||
find "./squashfs-root" -type d -name "*systemd*" -exec find "{}" -type f ! -name "*.so*" -delete \; | ||
P_SIZE="$(du -sh "./squashfs-root" 2>/dev/null | awk '{print $1}' 2>/dev/null)" && export "P_SIZE=${P_SIZE}" | ||
echo -e "\n[+] Shaved off ${O_SIZE} --> ${P_SIZE}\n" | ||
#Repack | ||
unset SOURCE_DATE_EPOCH | ||
cd "${SBUILD_OUTDIR}" && ARCH="$(uname -m)" appimagetool --comp "zstd" \ | ||
--mksquashfs-opt -root-owned \ | ||
--mksquashfs-opt -no-xattrs \ | ||
--mksquashfs-opt -noappend \ | ||
--mksquashfs-opt -b --mksquashfs-opt "1M" \ | ||
--mksquashfs-opt -mkfs-time --mksquashfs-opt "0" \ | ||
--mksquashfs-opt -Xcompression-level --mksquashfs-opt "22" \ | ||
--no-appstream "${SBUILD_TMPDIR}/squashfs-root" "${SBUILD_OUTDIR}/${PKG}" |