helm/modules/services/bitwarden.nix
Henrik Lissner 8ca2cc66ba mkdir /run/backups/bitwarden_rs
Since the service fails to do it itself.
2021-02-27 15:30:02 -05:00

35 lines
853 B
Nix

{ 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 {
services.bitwarden_rs = {
enable = true;
backupDir = "/run/backups/bitwarden_rs";
};
user.extraGroups = [ "bitwarden_rs" ];
services.fail2ban.jails.bitwarden_rs = ''
enabled = true
filter = bitwarden_rs
port = 80,443,8002
maxretry = 5
'';
# 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"
'';
};
}