about summary refs log tree commit diff
path: root/users/tazjin/emacs/default.nix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-12-13T15·31+0300
committerVincent Ambo <mail@tazj.in>2021-12-13T15·53+0300
commit2d330055977f0bdf6dcc41d886c122541a8672a9 (patch)
tree9815e6429aaa43fb89deccaf7b8ffd70dd13b8d3 /users/tazjin/emacs/default.nix
parent0fbd6f0aebc02fbdcbc363dd65c075206fb6fb72 (diff)
feat(tazjin/emacs): Check telega/tdlib compatibility in depot CI r/3216
This keeps biting me at runtime whenever these are out of sync.

Change-Id: If523974e6ad2754ea19123eda0e5fda0a865f408
Diffstat (limited to 'users/tazjin/emacs/default.nix')
-rw-r--r--users/tazjin/emacs/default.nix27
1 files changed, 27 insertions, 0 deletions
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
 ) {}