fix(3p/overlays): correctly assert tdlib<>telega.el matches

Extracts the required version out of the telega.el Dockerfile (this seems to be
the authoritative source), and matches that against what nixpkgs has.

In a future commit I'll improve this to reduce the likelihood of blocking a
channel bump (by also pinning tdlib, and issuing warnings when nixpkgs has a
newer telega/tdlib).

Change-Id: I1129c1f6b38aa58eb8661f2ad9bc6fa19382d81c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/13220
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
Vincent Ambo 2025-03-08 01:24:32 +03:00 committed by tazjin
parent 211c2d42fa
commit b32a95c206
2 changed files with 22 additions and 44 deletions

View file

@ -8,13 +8,9 @@ pkgs.makeOverridable
emacsPackages = (pkgs.emacsPackagesFor emacs);
emacsWithPackages = emacsPackages.emacsWithPackages;
# If switching telega versions, use this variable because it will
# keep the version check, binary path and so on in sync.
currentTelega = epkgs: epkgs.telega;
# $PATH for binaries that need to be available to Emacs
emacsBinPath = lib.makeBinPath [
(currentTelega pkgs.emacsPackages)
emacsPackages.checkedTelega
pkgs.libwebp # for dwebp, required by telega
];
@ -105,7 +101,7 @@ pkgs.makeOverridable
zoxide
# Wonky stuff
(currentTelega epkgs)
checkedTelega
customTreesitGrammars # TODO(tazjin): how is this *supposed* to work?!
# Custom depot packages (either ours, or overridden ones)
@ -121,29 +117,6 @@ pkgs.makeOverridable
# Dynamic/native modules
depot.users.tazjin.gio-list-apps
])));
# Tired of telega.el runtime breakages through tdlib
# incompatibility. Target to make that a build failure instead.
tdlibCheck =
let
tgEmacs = emacsWithPackages (epkgs: [ (currentTelega epkgs) ]);
verifyTdlibVersion = builtins.toFile "verify-tdlib-version.el" ''
(require 'telega)
(defvar tdlib-version "${pkgs.tdlib.version}")
(when (or (version< tdlib-version
telega-tdlib-min-version)
(and telega-tdlib-max-version
(version< telega-tdlib-max-version
tdlib-version)))
(message "Found TDLib version %s, but require %s to %s"
tdlib-version telega-tdlib-min-version telega-tdlib-max-version)
(kill-emacs 1))
'';
in
pkgs.runCommand "tdlibCheck" { } ''
export PATH="${emacsBinPath}:$PATH"
${tgEmacs}/bin/emacs --script ${verifyTdlibVersion} && touch $out
'';
in
lib.fix
(self: l: f: (pkgs.writeShellScriptBin "tazjins-emacs" ''
@ -173,11 +146,6 @@ pkgs.makeOverridable
# Call withLocalConfig with the path to a *folder* containing a
# `local.el` which provides local system configuration.
withLocalConfig = confDir: self confDir f;
# Expose telega/tdlib version check as a target that is built in
# CI.
inherit tdlibCheck;
meta.ci.targets = [ "tdlibCheck" ];
};
}))
null