at 25.11-pre 1.5 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8let 9 cfg = config.services.protonmail-bridge; 10in 11{ 12 options.services.protonmail-bridge = { 13 enable = lib.mkEnableOption "protonmail bridge"; 14 15 package = lib.mkPackageOption pkgs "protonmail-bridge" { }; 16 17 path = lib.mkOption { 18 type = lib.types.listOf lib.types.path; 19 default = [ ]; 20 example = lib.literalExpression "with pkgs; [ pass gnome-keyring ]"; 21 description = "List of derivations to put in protonmail-bridge's path."; 22 }; 23 24 logLevel = lib.mkOption { 25 type = lib.types.nullOr ( 26 lib.types.enum [ 27 "panic" 28 "fatal" 29 "error" 30 "warn" 31 "info" 32 "debug" 33 ] 34 ); 35 default = null; 36 description = "Log level of the Proton Mail Bridge service. If set to null then the service uses it's default log level."; 37 }; 38 }; 39 40 config = lib.mkIf cfg.enable { 41 systemd.user.services.protonmail-bridge = { 42 description = "protonmail bridge"; 43 wantedBy = [ "graphical-session.target" ]; 44 after = [ "graphical-session.target" ]; 45 46 serviceConfig = 47 let 48 logLevel = lib.optionalString (cfg.logLevel != null) "--log-level ${cfg.logLevel}"; 49 in 50 { 51 ExecStart = "${lib.getExe cfg.package} --noninteractive ${logLevel}"; 52 Restart = "always"; 53 }; 54 55 path = cfg.path; 56 }; 57 environment.systemPackages = [ cfg.package ]; 58 }; 59 meta.maintainers = with lib.maintainers; [ mzacho ]; 60}