Commit 658d249b8ec2

Vincent Demeester <vincent@sbr.pm>
2020-11-13 17:10:11
users/vincent: clean emacs services.
Use h-m emacs service and remove my own implementation. It is simpler and works better (socketActivation ๐Ÿ™ƒ) Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent acb20de
Changed files (4)
users/modules/services/default.nix
@@ -1,5 +1,4 @@
 {
   imports = [
-    ./emacs-server.nix
   ];
 }
users/modules/services/emacs-server.nix
@@ -1,56 +0,0 @@
-{ config, lib, pkgs, ... }:
-with lib;
-let
-  cfg = config.services.emacs-server;
-in
-{
-  options.services.emacs-server = {
-    enable = mkEnableOption "the Emacs daemon";
-    name = mkOption {
-      type = types.str;
-      description = "Name of the emacs server";
-      default = "default";
-    };
-    package = mkOption {
-      type = types.package;
-      description = "The Emacs package to use for running the daemon.";
-    };
-    shell = mkOption {
-      type = types.str;
-      description = "The shell used for starting Emacs.";
-    };
-    extraOptions = mkOption {
-      type = types.separatedString " ";
-      default = "";
-      description =
-        ''
-          The extra command-line options to pass to
-          <command>emacs</command> daemon.
-        '';
-    };
-  };
-
-  config = mkIf cfg.enable {
-    systemd.user.services.emacs-server = {
-      Unit = {
-        Description = "Emacs: the extensible, self-documenting text editor";
-        Documentation =
-          "info:emacs man:emacs(1) https://gnu.org/software/emacs/";
-
-        # Avoid killing the Emacs session, which may be full of
-        # unsaved buffers.
-        X-RestartIfChanged = false;
-      };
-
-      Service = {
-        ExecStart =
-          "${cfg.shell} 'exec emacs --fg-daemon=${cfg.name} ${cfg.extraOptions}'";
-        ExecStop = "${cfg.shell} 'emacsclient --eval '(kill-emacs)''";
-        Restart = "on-failure";
-        Environment = "DISPLAY=:0";
-      };
-
-      Install = { WantedBy = [ "default.target" ]; };
-    };
-  };
-}
users/vincent/dev/emacs/org-protocol.desktop
@@ -1,6 +1,6 @@
 [Desktop Entry]
 Name=org-protocol
-Exec=emacsclient -s /run/user/1000/emacs/org -n %u
+Exec=emacsclient -n %u
 Type=Application
 Terminal=false
 Categories=System;
users/vincent/dev/emacs.nix
@@ -5,7 +5,7 @@ with lib;
 let
   capture = pkgs.writeScriptBin "capture" ''
     #!${pkgs.stdenv.shell}
-    emacsclient -s /run/user/1000/emacs/org -n -F '((name . "capture") (width . 150) (height . 90))' -e '(org-capture)'
+    emacsclient -n -F '((name . "capture") (width . 150) (height . 90))' -e '(org-capture)'
   '';
   e = pkgs.writeScriptBin "e" ''
     #!${pkgs.stdenv.shell}
@@ -13,11 +13,11 @@ let
   '';
   et = pkgs.writeScriptBin "et" ''
     #!${pkgs.stdenv.shell}
-    emacsclient -s /run/user/1000/emacs/org --tty $@
+    emacsclient --tty $@
   '';
   ec = pkgs.writeScriptBin "ec" ''
     #!${pkgs.stdenv.shell}
-    emacsclient -s /run/user/1000/emacs/org --create-frame $@
+    emacsclient --create-frame $@
   '';
   myExtraPackages = epkgs: with epkgs; [
     ace-window
@@ -149,12 +149,6 @@ in
     client.enable = true;
     socketActivation.enable = true;
   };
-  services.emacs-server = {
-    enable = true;
-    package = pkgs.my.emacs;
-    name = "org";
-    shell = pkgs.zsh + "/bin/zsh -i -c";
-  };
   home.sessionVariables = {
     EDITOR = "emacs";
     ALTERNATE_EDITOR = "emacs -nw";