nur-packages

My NUR packages
git clone git://git.sikmir.ru/nur-packages
Log | Files | Refs | README | LICENSE

aerc.nix (1924B)


      1 { config, lib, pkgs, ... }:
      2 
      3 with lib;
      4 let
      5   cfg = config.programs.aerc;
      6   configDir = "${config.xdg.configHome}/aerc";
      7 
      8   accountConfFile = with cfg;
      9     generators.toINI
     10       { }
     11       {
     12         Personal = {
     13           source = "imaps://${gUsername}:${gPassword}@imap.gmail.com:993";
     14           outgoing = "smtp+plain://${gUsername}:${gPassword}@smtp.gmail.com:587";
     15           default = "INBOX";
     16           smtp-starttls = "yes";
     17           from =
     18             if fullName != "" then
     19               "${fullName} <${gUsername}@gmail.com>"
     20             else
     21               "${gUsername}@gmail.com";
     22           copy-to = "Sent";
     23         };
     24       };
     25 
     26   activationScript = ''
     27     $DRY_RUN_CMD install -Dm644 ${pkgs.aerc}/share/aerc/aerc.conf -t ${configDir}
     28     $DRY_RUN_CMD install -Dm644 ${pkgs.aerc}/share/aerc/binds.conf -t ${configDir}
     29   '' + optionalString (cfg.gUsername != "" && cfg.gPassword != "") ''
     30     $DRY_RUN_CMD eval "echo '${accountConfFile}' > ${configDir}/accounts.conf"
     31     $DRY_RUN_CMD chmod 600 ${configDir}/accounts.conf
     32   '';
     33 in
     34 {
     35   meta.maintainers = [ maintainers.sikmir ];
     36 
     37   options.programs.aerc = {
     38     enable = mkEnableOption "aerc is an email client for your terminal";
     39 
     40     package = mkOption {
     41       type = types.package;
     42       default = pkgs.aerc;
     43       defaultText = literalExpression "pkgs.aerc";
     44       description = "aerc package to install.";
     45     };
     46 
     47     gUsername = mkOption {
     48       type = types.str;
     49       default = "";
     50       description = "Google username.";
     51     };
     52 
     53     gPassword = mkOption {
     54       type = types.str;
     55       default = "";
     56       description = "Google app password.";
     57     };
     58 
     59     fullName = mkOption {
     60       type = types.str;
     61       default = "";
     62       description = "Full name.";
     63     };
     64   };
     65 
     66   config = mkIf cfg.enable {
     67     home.packages = [ cfg.package ];
     68 
     69     home.activation = {
     70       accountsConf = lib.hm.dag.entryAfter [ "writeBoundary" ] activationScript;
     71     };
     72   };
     73 }