diff --git a/platforms/home-manager/modules/nmasur/presets/programs/msmtp-system.nix b/platforms/home-manager/modules/nmasur/presets/programs/msmtp-system.nix deleted file mode 100644 index 095ad89..0000000 --- a/platforms/home-manager/modules/nmasur/presets/programs/msmtp-system.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ - config, - pkgs, - lib, - ... -}: - -let - cfg = config.nmasur.presets.programs.msmtp-system; -in - -{ - - options.nmasur.presets.programs.msmtp-system.enable = lib.mkEnableOption "System outgoing mail"; - - config = lib.mkIf cfg.enable { - programs.msmtp.enable = true; - - # The system user for sending automatic notifications - accounts.email.accounts.system = - let - address = "system@${config.mail.server}"; - in - { - userName = address; - realName = "NixOS System"; - primary = !config.mail.enable; # Only primary if mail not enabled - inherit address; - passwordCommand = "${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${pkgs.writeText "mailpass-system.age" (builtins.readFile ../../../private/mailpass-system.age)}"; - msmtp.enable = true; - smtp = { - host = config.mail.smtpHost; - port = 465; - tls.enable = true; - }; - }; - - }; -} diff --git a/platforms/nixos/modules/nmasur/presets/programs/msmtp.nix b/platforms/nixos/modules/nmasur/presets/programs/msmtp.nix new file mode 100644 index 0000000..52db089 --- /dev/null +++ b/platforms/nixos/modules/nmasur/presets/programs/msmtp.nix @@ -0,0 +1,47 @@ +{ + config, + pkgs, + lib, + ... +}: + +let + cfg = config.nmasur.presets.programs.msmtp; +in + +{ + + options.nmasur.presets.programs.msmtp = { + enable = lib.mkEnableOption "System outgoing mail"; + host = lib.mkOption { + type = lib.types.str; + description = "Hostname for SMTP"; + default = config.mail.smtpHost; + }; + user = lib.mkOption { + type = lib.types.str; + description = "system@${config.mail.server}"; + default = config.mail.smtpHost; + }; + }; + + config = lib.mkIf cfg.enable { + programs.msmtp = { + enable = true; + setSendmail = true; + accounts = { + # The system user for sending automatic notifications + default = { + auth = true; + host = cfg.host; + passwordeval = "${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${pkgs.writeText "mailpass-system.age" (builtins.readFile ../../../private/mailpass-system.age)}"; + user = cfg.user; + from_full_name = "${config.networking.hostName} System"; + port = 465; + tls = true; + }; + }; + }; + + }; +} diff --git a/platforms/nixos/modules/secrets.nix b/platforms/nixos/modules/secrets.nix index a13f2bb..942d001 100644 --- a/platforms/nixos/modules/secrets.nix +++ b/platforms/nixos/modules/secrets.nix @@ -24,7 +24,7 @@ in default = "/var/private"; }; - secretsIdentityFile = lib.mkOption { + identityFile = lib.mkOption { type = lib.types.path; description = "Path containing decryption identity."; };