commit c2282fe4c4f12337800701a117cbc372e24994a2
parent f502a3106084d4a3b5517db15e0c05e1a61c7c45
Author: Nikolay Korotkiy <sikmir@gmail.com>
Date: Fri, 24 Apr 2020 08:41:00 +0300
Add aerc module
Diffstat:
2 files changed, 70 insertions(+), 0 deletions(-)
diff --git a/modules/default.nix b/modules/default.nix
@@ -1,6 +1,7 @@
{
home-manager = {
programs = {
+ aerc = ./home-manager/programs/aerc.nix;
goldendict = ./home-manager/programs/goldendict.nix;
gpxsee = ./home-manager/programs/gpxsee.nix;
qmapshack = ./home-manager/programs/qmapshack.nix;
diff --git a/modules/home-manager/programs/aerc.nix b/modules/home-manager/programs/aerc.nix
@@ -0,0 +1,69 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+ cfg = config.programs.aerc;
+
+ accountConfFile = with cfg; generators.toINI {} {
+ Personal = {
+ source = "imaps://${gUsername}:${gPassword}@imap.gmail.com:993";
+ outgoing = "smtp+plain://${gUsername}:${gPassword}@smtp.gmail.com:587";
+ default = "INBOX";
+ smtp-starttls = "yes";
+ from =
+ if fullName != "" then
+ "${fullName} <${gUsername}@gmail.com>"
+ else
+ "${gUsername}@gmail.com";
+ copy-to = "Sent";
+ };
+ };
+
+ activationScript = with config.xdg; ''
+ $DRY_RUN_CMD install -Dm644 ${pkgs.aerc}/share/aerc/aerc.conf -t ${configHome}/aerc
+ $DRY_RUN_CMD install -Dm644 ${pkgs.aerc}/share/aerc/binds.conf -t ${configHome}/aerc
+ '' + optionalString (cfg.gUsername != "" && cfg.gPassword != "") ''
+ $DRY_RUN_CMD eval "echo '${accountConfFile}' > ${configHome}/aerc/accounts.conf"
+ $DRY_RUN_CMD chmod 600 ${configHome}/aerc/accounts.conf
+ '';
+in
+{
+ meta.maintainers = with maintainers; [ sikmir ];
+
+ options.programs.aerc = {
+ enable = mkEnableOption "aerc is an email client for your terminal";
+
+ package = mkOption {
+ type = types.package;
+ default = pkgs.aerc;
+ defaultText = literalExample "pkgs.aerc";
+ description = "aerc package to install.";
+ };
+
+ gUsername = mkOption {
+ type = types.str;
+ default = "";
+ description = "Google username.";
+ };
+
+ gPassword = mkOption {
+ type = types.str;
+ default = "";
+ description = "Google app password.";
+ };
+
+ fullName = mkOption {
+ type = types.str;
+ default = "";
+ description = "Full name.";
+ };
+ };
+
+ config = mkIf cfg.enable {
+ home.packages = [ cfg.package ];
+
+ home.activation = {
+ accountsConf = config.lib.dag.entryAfter [ "writeBoundary" ] activationScript;
+ };
+ };
+}