summaryrefslogtreecommitdiff
path: root/home/config/emacs.nix
blob: 50fd2132653fb64fdc3a011d2eb8fe1f2405f12c (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
50
51
{ config, lib, pkgs, ... }:

let
  cfg = config.programs.emacs;
  spacemacs-update-script = pkgs.callPackage ({ emacs, git }:
    pkgs.writeShellApplication {
      name = "spacemacs-update";

      runtimeInputs = [ emacs git ];

      text = ''
        git checkout develop
        git pull
        git checkout local
        git merge develop
        emacsclient --eval '(configuration-layer/update-packages "no-confirmation")'
      '';
    }) { emacs = cfg.package; };
in {
  programs.emacs = {
    enable = true;
    package =
      pkgs.emacsWithPackages (ep: with ep; [ emacsql-sqlite emacsql-sqlite3 ]);
  };
  services.emacs = {
    enable = true;
    client.enable = true;
  };

  home.packages = with pkgs; [ gnutar ];

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

  systemd.user = lib.mkIf cfg.enable
    (pkgs.personal.lib.serviceWithTimer "spacemacs-update" {
      Unit = {
        Description = "Update Spacemacs by pulling the develop branch";
        After = [ "network-online.target" "emacs.service" ];
      };
      Service = {
        Type = "oneshot";
        WorkingDirectory = "${config.home.homeDirectory}/.emacs.d/";
        ExecStart = "${spacemacs-update-script}";
      };
      Timer = {
        Persistent = true;
        OnCalendar = "daily";
      };
      Install = { WantedBy = [ "default.target" ]; };
    });
}