Commit 4bef2be1dd7c

Vincent Demeester <vincent@sbr.pm>
2026-01-08 16:38:23
fix(emacs): Build without GUI features on server systems
- Prevent D-Bus session errors when running Emacs in terminal - Reduce server build size by excluding X11/GTK dependencies - Preserve full GUI support on desktop systems Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 1918240
Changed files (1)
home
common
home/common/dev/emacs.nix
@@ -1,6 +1,7 @@
 {
   config,
   pkgs,
+  desktop ? null,
   ...
 }:
 let
@@ -192,14 +193,16 @@ in
   ];
   programs.emacs = {
     enable = true;
-    # FIXME: choose depending on the enabled modules
-    #package = (pkgs.emacs29.override { withTreeSitter = true; withNativeCompilation = true; withPgtk = true; withWebP = true; withGTK3 = true; withSQLite3 = true; });
+    # Build Emacs with GUI support (GTK3/PGTK/X11) only on desktop systems
+    # On servers, use terminal-only build to avoid D-Bus dependency
     package = pkgs.emacs-unstable.override {
       withTreeSitter = true;
       withNativeCompilation = true;
-      withPgtk = true;
-      withWebP = true;
-      withGTK3 = true;
+      # Only enable GUI features when desktop is configured
+      withX = desktop != null;
+      withPgtk = desktop != null;
+      withWebP = desktop != null;
+      withGTK3 = desktop != null;
       withSQLite3 = true;
     };
     extraPackages = myExtraPackages;