From 2d330055977f0bdf6dcc41d886c122541a8672a9 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 13 Dec 2021 18:31:25 +0300 Subject: feat(tazjin/emacs): Check telega/tdlib compatibility in depot CI This keeps biting me at runtime whenever these are out of sync. Change-Id: If523974e6ad2754ea19123eda0e5fda0a865f408 --- users/tazjin/emacs/default.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'users') diff --git a/users/tazjin/emacs/default.nix b/users/tazjin/emacs/default.nix index a13a697648ee..66f24945560f 100644 --- a/users/tazjin/emacs/default.nix +++ b/users/tazjin/emacs/default.nix @@ -105,6 +105,28 @@ let tvlPackages.term-switcher tvlPackages.tvl ]))); + + # 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 + (plist-get telega--options :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.runCommandNoCC "tdlibCheck" {} '' + export PATH="${emacsBinPath}:$PATH" + ${tgEmacs}/bin/emacs --script ${verifyTdlibVersion} && touch $out + ''; in lib.fix(self: l: f: pkgs.writeShellScriptBin "tazjins-emacs" '' export PATH="${emacsBinPath}:$PATH" exec ${tazjinsEmacs f}/bin/emacs \ @@ -137,5 +159,10 @@ in lib.fix(self: l: f: pkgs.writeShellScriptBin "tazjins-emacs" '' ${if l != null then "--directory ${l}" else ""} \ --eval "(require 'init)" $@ ''; + + # Expose telega/tdlib version check as a target that is built in + # CI. + inherit tdlibCheck; + meta.targets = [ "tdlibCheck" ]; }) null identity ) {} -- cgit 1.4.1