Add modules/shell/bitwarden module

For bitwarden-cli
This commit is contained in:
Henrik Lissner 2020-12-21 22:38:49 -05:00
parent 6b43fcb14d
commit e74a392d76
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 28 additions and 0 deletions

View file

@ -25,4 +25,7 @@ with lib;
latitude = 55.88; latitude = 55.88;
longitude = 12.5; longitude = 12.5;
} else {}); } else {});
##
modules.shell.bitwarden.config.server = "p.v0.io";
} }

View file

@ -0,0 +1,25 @@
{ 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)}
'';
};
};
}