summaryrefslogtreecommitdiff
path: root/home/config/emacs.nix
blob: 4b70090d9587c7c72ead18fcdb8685e209d1b2aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{ config, lib, pkgs, ... }:

let cfg = config.programs.emacs;
in {
  programs.emacs = {
    enable = true;
    # package = pkgs.emacs.overrideAttrs (oldAttrs: rec { nativeComp = true; });
  };
  services.emacs = {
    enable = true;
    client.enable = true;
  };

  home.file.".spacemacs.d/init.el".source = ./dotfiles/spacemacs;

  systemd.user = lib.mkIf cfg.enable {
    services.update-spacemacs = {
      Unit = {
        Description = "Update Spacemacs by pulling the develop branch";
        After = [ "network-online.target" ];
        X-RestartIfChanged = true;
      };

      Service = {
        Type = "oneshot";
        WorkingDirectory = "${config.home.homeDirectory}/.emacs.d/";
        ExecStart =
          "${pkgs.git}/bin/git pull ; ${cfg.package}/bin/emacsclient --eval '(configuration-layer/update-packages)'";
      };

      Install.WantedBy = [ "default.target" ];
    };
    timers.update-spacemacs = {
      Unit = {
        Description = "Run Spacemacs update periodically";
        After = [ "network-online.target" ];
        X-RestartIfChanged = true;
      };

      Timer = {
        Unit = "update-spacemacs.service";
        Persistent = true;
        OnCalendar = "daily";
      };

      Install.WantedBy = [ "default.target" ];
    };
  };
}