config/modules/home/services/pm-bridge/default.nix

49 lines
1.1 KiB
Nix
Raw Normal View History

2024-09-21 18:49:15 -04:00
{
lib,
config,
pkgs,
...
}:
with lib;
with lib.custom; let
cfg = config.services.pm-bridge;
in {
options.services.pm-bridge = with types; {
2024-10-18 23:59:23 -04:00
enable = mkOption {
type = types.bool;
default = false;
description = "Whether to enable the Bridge.";
};
2024-09-21 18:49:15 -04:00
2024-10-18 23:59:23 -04:00
nonInteractive = mkOption {
type = types.bool;
default = false;
description = "Start Bridge entirely noninteractively";
};
2024-09-21 18:49:15 -04:00
2024-10-18 23:59:23 -04:00
logLevel = mkOption {
type = types.enum ["panic" "fatal" "error" "warn" "info" "debug" "debug-client" "debug-server"];
default = "info";
description = "The log level";
2024-09-21 18:49:15 -04:00
};
};
config = mkIf cfg.enable {
systemd.user.services.protonmail-bridge = {
Unit = {
2024-10-18 23:59:23 -04:00
Description = "Protonmail Bridge";
After = ["network.target"];
2024-09-21 18:49:15 -04:00
};
2024-10-18 23:59:23 -04:00
Service = {
2024-09-21 18:49:15 -04:00
Restart = "always";
2024-10-18 23:59:23 -04:00
ExecStart = "${pkgs.protonmail-bridge}/bin/protonmail-bridge --no-window --log-level ${cfg.logLevel}" + optionalString (cfg.nonInteractive) " --noninteractive";
2024-09-21 18:49:15 -04:00
};
2024-10-18 23:59:23 -04:00
2024-09-21 18:49:15 -04:00
Install = {
2024-10-18 23:59:23 -04:00
WantedBy = ["default.target"];
2024-09-21 18:49:15 -04:00
};
};
};
}