From d5887d64d96183c802bf925bc0e279901ec278f4 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sat, 17 Sep 2022 13:13:13 +0200 Subject: home: emacs: add service to autoupdate spacemacs --- home/config/emacs.nix | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'home/config/emacs.nix') diff --git a/home/config/emacs.nix b/home/config/emacs.nix index c12f917..4b70090 100644 --- a/home/config/emacs.nix +++ b/home/config/emacs.nix @@ -1,6 +1,7 @@ -{ pkgs, ... }: +{ config, lib, pkgs, ... }: -{ +let cfg = config.programs.emacs; +in { programs.emacs = { enable = true; # package = pkgs.emacs.overrideAttrs (oldAttrs: rec { nativeComp = true; }); @@ -11,6 +12,38 @@ }; home.file.".spacemacs.d/init.el".source = ./dotfiles/spacemacs; - home.file.".emacs.d/private/layers/why3/local/why3.backup".source = - "${pkgs.why3}/share/emacs/site-lisp"; + + 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" ]; + }; + }; } -- cgit v1.2.3