helm/modules/shell/bitwarden.nix
Henrik Lissner e74a392d76
Add modules/shell/bitwarden module
For bitwarden-cli
2020-12-21 22:46:17 -05:00

26 lines
599 B
Nix

{ config, options, pkgs, lib, ... }:
with lib;
with lib.my;
let cfg = config.modules.shell.bitwarden;
in {
options.modules.shell.bitwarden = with types; {
enable = mkBoolOpt false;
config = mkOpt attrs {};
};
config = mkIf cfg.enable {
user.packages = with pkgs; [
bitwarden-cli
];
modules.shell.zsh.rcInit = "_cache bw completion --shell zsh; compdef _bw bw;";
system.userActivationScripts = mkIf (cfg.config != {}) {
initBitwarden = ''
${concatStringsSep "\n" (mapAttrsToList (n: v: "bw config ${n} ${v}") cfg.config)}
'';
};
};
}