mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
protonmail-bridge: init module
This commit is contained in:
parent
8275e5d315
commit
1daeb0638a
5 changed files with 119 additions and 0 deletions
13
modules/misc/news/2025/08/2025-08-13_16-34-57.nix
Normal file
13
modules/misc/news/2025/08/2025-08-13_16-34-57.nix
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
time = "2025-08-13T21:34:57+00:00";
|
||||||
|
condition = pkgs.stdenv.hostPlatform.isLinux;
|
||||||
|
message = ''
|
||||||
|
A new module is available: 'services.protonmail-bridge'.
|
||||||
|
|
||||||
|
ProtonMail Bridge is a desktop application that runs in the background,
|
||||||
|
encrypting and decrypting messages as they enter and leave your computer.
|
||||||
|
It lets you add your ProtonMail account to your favorite email client via
|
||||||
|
IMAP/SMTP by creating a local email server on your computer.
|
||||||
|
'';
|
||||||
|
}
|
||||||
71
modules/services/protonmail-bridge.nix
Normal file
71
modules/services/protonmail-bridge.nix
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.protonmail-bridge;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
meta.maintainers = with lib.hm.maintainers; [ epixtm ];
|
||||||
|
|
||||||
|
options.services.protonmail-bridge = {
|
||||||
|
enable = lib.mkEnableOption "ProtonMail Bridge";
|
||||||
|
package = lib.mkPackageOption pkgs "protonmail-bridge" { };
|
||||||
|
|
||||||
|
extraPackages = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.package;
|
||||||
|
default = [ ];
|
||||||
|
example = lib.literalExpression "with pkgs; [ pass gnome-keyring ]";
|
||||||
|
description = "List of derivations to place in ProtonMail Bridge's service path.";
|
||||||
|
};
|
||||||
|
|
||||||
|
logLevel = lib.mkOption {
|
||||||
|
type = lib.types.nullOr (
|
||||||
|
lib.types.enum [
|
||||||
|
"panic"
|
||||||
|
"fatal"
|
||||||
|
"error"
|
||||||
|
"warn"
|
||||||
|
"info"
|
||||||
|
"debug"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Log level of the ProtonMail Bridge service.
|
||||||
|
|
||||||
|
If set to null, the service uses its default log level.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
assertions = [
|
||||||
|
(lib.hm.assertions.assertPlatform "services.protonmail-bridge" pkgs lib.platforms.linux)
|
||||||
|
];
|
||||||
|
|
||||||
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
|
systemd.user.services.protonmail-bridge = {
|
||||||
|
Unit = {
|
||||||
|
Description = "ProtonMail Bridge";
|
||||||
|
After = [ "graphical-session.target" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
Service = {
|
||||||
|
Environment = lib.mkIf (cfg.extraPackages != [ ]) [ "PATH=${lib.makeBinPath cfg.extraPackages}" ];
|
||||||
|
ExecStart =
|
||||||
|
"${lib.getExe cfg.package} --noninteractive"
|
||||||
|
+ lib.optionalString (cfg.logLevel != null) " --log-level ${cfg.logLevel}";
|
||||||
|
Restart = "always";
|
||||||
|
};
|
||||||
|
|
||||||
|
Install = {
|
||||||
|
WantedBy = [ "graphical-session.target" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
services.protonmail-bridge = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.protonmail-bridge-gui;
|
||||||
|
extraPackages = with pkgs; [
|
||||||
|
gnome-keyring
|
||||||
|
];
|
||||||
|
logLevel = "info";
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
local service="home-files/.config/systemd/user/protonmail-bridge.service"
|
||||||
|
|
||||||
|
assertFileExists $service
|
||||||
|
assertFileRegex $service 'Environment=PATH=.*gnome-keyring.*'
|
||||||
|
assertFileRegex $service 'ExecStart=.*/protonmail-bridge-gui --noninteractive --log-level info'
|
||||||
|
'';
|
||||||
|
}
|
||||||
5
tests/modules/services/protonmail-bridge/default.nix
Normal file
5
tests/modules/services/protonmail-bridge/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{ lib, pkgs, ... }:
|
||||||
|
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||||
|
protonmail-bridge-basic-configuration = ./basic-configuration.nix;
|
||||||
|
protonmail-bridge-empty-settings = ./empty-settings.nix;
|
||||||
|
}
|
||||||
11
tests/modules/services/protonmail-bridge/empty-settings.nix
Normal file
11
tests/modules/services/protonmail-bridge/empty-settings.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
services.protonmail-bridge.enable = true;
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
local service="home-files/.config/systemd/user/protonmail-bridge.service"
|
||||||
|
|
||||||
|
assertFileExists $service
|
||||||
|
assertFileNotRegex $service 'Environment=PATH=.*'
|
||||||
|
assertFileRegex $service 'ExecStart=.*/protonmail-bridge --noninteractive'
|
||||||
|
'';
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue