merge
This commit is contained in:
65
modules/nixos/protonmail-bridge/default.nix
Normal file
65
modules/nixos/protonmail-bridge/default.nix
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
namespace,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.${namespace}.services.protonmail-bridge;
|
||||
in
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# Open firewall for protonmail bridge if enabled
|
||||
networking.firewall = mkIf cfg.openFirewall {
|
||||
allowedTCPPorts = [
|
||||
cfg.smtpPort
|
||||
cfg.imapPort
|
||||
];
|
||||
allowedUDPPorts = [
|
||||
cfg.smtpPort
|
||||
cfg.imapPort
|
||||
];
|
||||
};
|
||||
|
||||
# Install protonmail-bridge package
|
||||
environment.systemPackages = with pkgs; [
|
||||
protonmail-bridge
|
||||
gnome-keyring
|
||||
gnupg
|
||||
pass
|
||||
];
|
||||
|
||||
# Configure systemd user service for protonmail-bridge
|
||||
systemd.user.services.protonmail-bridge = {
|
||||
description = "Protonmail Bridge";
|
||||
enable = true;
|
||||
environment = {
|
||||
GNUPGHOME = "%h/.gnupg";
|
||||
PASSWORD_STORE_DIR = "%h/.password-store";
|
||||
};
|
||||
script = "${pkgs.protonmail-bridge}/bin/protonmail-bridge --noninteractive";
|
||||
path = with pkgs; [
|
||||
gnome-keyring
|
||||
gnupg
|
||||
pass
|
||||
protonmail-bridge
|
||||
];
|
||||
wantedBy = [ "default.target" ];
|
||||
after = [ "gpg-agent.service" ];
|
||||
};
|
||||
|
||||
# Enable gnome keyring for password storage
|
||||
security.pam.services.login.enableGnomeKeyring = true;
|
||||
services.gnome.gnome-keyring.enable = true;
|
||||
|
||||
# Configure gpg-agent
|
||||
programs.gnupg.agent = {
|
||||
enable = true;
|
||||
enableSSHSupport = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
31
modules/nixos/protonmail-bridge/options.nix
Normal file
31
modules/nixos/protonmail-bridge/options.nix
Normal file
@@ -0,0 +1,31 @@
|
||||
{ lib, namespace, ... }:
|
||||
with lib;
|
||||
{
|
||||
options.${namespace}.services.protonmail-bridge = {
|
||||
enable = mkEnableOption "protonmail bridge service";
|
||||
|
||||
smtpPort = mkOption {
|
||||
type = types.port;
|
||||
default = 1025;
|
||||
description = "SMTP port for protonmail bridge";
|
||||
};
|
||||
|
||||
imapPort = mkOption {
|
||||
type = types.port;
|
||||
default = 1143;
|
||||
description = "IMAP port for protonmail bridge";
|
||||
};
|
||||
|
||||
openFirewall = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Whether to open firewall for protonmail bridge";
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
default = "admin";
|
||||
description = "User to run protonmail bridge as";
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user