From 91e1c5349e75424bdcb1f81d696b4063a8722a80 Mon Sep 17 00:00:00 2001 From: Martin Zacho Date: Tue, 6 Aug 2024 00:57:22 +0200 Subject: [PATCH] nixos/modules/services/mail: add protonmail-bridge --- .../manual/release-notes/rl-2411.section.md | 2 + nixos/modules/module-list.nix | 1 + .../services/mail/protonmail-bridge.nix | 59 +++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 nixos/modules/services/mail/protonmail-bridge.nix diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index a1ee21a4e099..03574e9b0ced 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -74,6 +74,8 @@ - [Rathole](https://github.com/rapiz1/rathole), a lightweight and high-performance reverse proxy for NAT traversal. Available as [services.rathole](#opt-services.rathole.enable). +- [Proton Mail bridge](https://proton.me/mail/bridge), a desktop application that runs in the background, encrypting and decrypting messages as they enter and leave your computer. It lets you add your Proton Mail account to your favorite email client via IMAP/SMTP by creating a local email server on your computer. + ## Backward Incompatibilities {#sec-release-24.11-incompatibilities} - `transmission` package has been aliased with a `trace` warning to `transmission_3`. Since [Transmission 4 has been released last year](https://github.com/transmission/transmission/releases/tag/4.0.0), and Transmission 3 will eventually go away, it was decided perform this warning alias to make people aware of the new version. The `services.transmission.package` defaults to `transmission_3` as well because the upgrade can cause data loss in certain specific usage patterns (examples: [#5153](https://github.com/transmission/transmission/issues/5153), [#6796](https://github.com/transmission/transmission/issues/6796)). Please make sure to back up to your data directory per your usage: diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 31bd31bca024..8c9c68c68eb6 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -673,6 +673,7 @@ ./services/mail/postfixadmin.nix ./services/mail/postgrey.nix ./services/mail/postsrsd.nix + ./services/mail/protonmail-bridge.nix ./services/mail/public-inbox.nix ./services/mail/roundcube.nix ./services/mail/rspamd.nix diff --git a/nixos/modules/services/mail/protonmail-bridge.nix b/nixos/modules/services/mail/protonmail-bridge.nix new file mode 100644 index 000000000000..c46d5ffe14a6 --- /dev/null +++ b/nixos/modules/services/mail/protonmail-bridge.nix @@ -0,0 +1,59 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.services.protonmail-bridge; +in +{ + options.services.protonmail-bridge = { + enable = lib.mkEnableOption "protonmail bridge"; + + package = lib.mkPackageOption pkgs "protonmail-bridge" { }; + + path = lib.mkOption { + type = lib.types.listOf lib.types.path; + default = [ ]; + example = lib.literalExpression "with pkgs; [ pass gnome-keyring ]"; + description = "List of derivations to put in protonmail-bride's path."; + }; + + logLevel = lib.mkOption { + type = lib.types.nullOr ( + lib.types.enum [ + "panic" + "fatal" + "error" + "warn" + "info" + "debug" + ] + ); + default = null; + description = "Log level of the Proton Mail Bridge service. If set to null then the service uses it's default log level."; + }; + }; + + config = lib.mkIf cfg.enable { + systemd.user.services.protonmail-bridge = { + description = "protonmail bridge"; + wantedBy = [ "graphical-session.target" ]; + after = [ "graphical-session.target" ]; + + serviceConfig = + let + logLevel = lib.optionalString (cfg.logLevel != null) "--log-level ${cfg.logLevel}"; + in + { + ExecStart = "${lib.getExe cfg.package} --noninteractive ${logLevel}"; + Restart = "always"; + }; + + path = cfg.path; + }; + environment.systemPackages = [ cfg.package ]; + }; +}