2020-12-18 20:42:52 -08:00
|
|
|
{ options, config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
with lib.my;
|
|
|
|
let cfg = config.modules.services.bitwarden;
|
|
|
|
in {
|
|
|
|
options.modules.services.bitwarden = {
|
|
|
|
enable = mkBoolOpt false;
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-02-22 07:40:22 -08:00
|
|
|
services.bitwarden_rs = {
|
|
|
|
enable = true;
|
|
|
|
backupDir = "/run/backups/bitwarden_rs";
|
|
|
|
};
|
2021-01-01 18:19:06 -08:00
|
|
|
|
2020-12-19 05:05:05 -08:00
|
|
|
user.extraGroups = [ "bitwarden_rs" ];
|
2021-01-01 18:19:06 -08:00
|
|
|
|
|
|
|
services.fail2ban.jails.bitwarden_rs = ''
|
|
|
|
enabled = true
|
|
|
|
filter = bitwarden_rs
|
|
|
|
port = 80,443,8002
|
2021-01-31 15:43:29 -08:00
|
|
|
maxretry = 5
|
2021-01-01 18:19:06 -08:00
|
|
|
'';
|
2021-02-27 12:19:43 -08:00
|
|
|
|
|
|
|
# HACK services.bitwarden_rs errors about permissions trying to create
|
|
|
|
# backupDir in /run/backups, so we do it for it.
|
|
|
|
system.activationScripts.bitwardenCreateDirs = ''
|
|
|
|
DIR="${config.services.bitwarden_rs.backupDir}"
|
|
|
|
mkdir -m 750 -p "$DIR" || true
|
|
|
|
chown bitwarden_rs:bitwarden_rs "$DIR"
|
|
|
|
'';
|
2020-12-18 20:42:52 -08:00
|
|
|
};
|
|
|
|
}
|