{ config, pkgs, lib, ... }:

let
  cfg = config.subs.emacs;
in
{
  options.subs.emacs.enable = lib.mkOption {
    default = false;
    type = lib.types.bool;
  };

  config = lib.mkIf cfg.enable {
    programs.emacs.enable = true;
    services.emacs = {
      enable = true;
      package = pkgs.emacs;
      client.enable = true;
      client.arguments = [ "-ca" ];
      startWithUserSession = "graphical";
    };
    home.file = {
      ".spacemacs".source = ../../config/spacemacs;
    };
  };
}
