config/modules/home/services/pm-bridge/default.nix
2024-10-18 23:59:23 -04:00

48 lines
1.1 KiB
Nix

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