nixos/home/modules/rbw.nix

43 lines
1.2 KiB
Nix
Raw Permalink Normal View History

2024-08-24 21:01:19 +00:00
{ config, lib, pkgs, ... }:
let
cfg = config.snowhawk.rbw;
2024-08-24 22:13:20 +00:00
rbw-fzf = pkgs.writeShellApplication {
name = "rbw-fzf";
runtimeInputs = with pkgs; [ rbw fzf perl findutils coreutils jq ];
text = /*bash*/ ''
rbw ls --fields name,user |
sort -bi |
perl -ple 's/^([^\t]*)\t([^\t]*)$/$1 ($2)/gm' |
fzf --tmux --no-sort --with-shell='bash -c' \
--preview="echo {} | perl -plE 's/^(.*) \((.*)?\)$/\"\$1\" \"\$2\"/' |
xargs rbw get --full --raw | \
jq --color-output 'if .data.password != \"\" then setpath([\"data\", \"password\"]; \"************\") else . end | del(.history) | del(.id) | walk(if type == \"object\" then map_values(. // empty) else . end)'" \
--preview-label="Vault Item" --preview-window=wrap |
perl -plE 's/^(.*) \((.*)?\)$/"$1" "$2"/' |
xargs -r rbw get |
2024-08-24 22:15:55 +00:00
xclip -sel copy
2024-08-24 22:13:20 +00:00
'';
};
2024-08-24 21:01:19 +00:00
inherit (lib) mkIf mkEnableOption;
in
{
options.snowhawk.rbw = {
enable = mkEnableOption "rbw home-manager module";
};
config = mkIf cfg.enable {
programs.rbw.enable = true;
2024-08-24 22:13:20 +00:00
home.packages =
with pkgs; [
rbw
pinentry-tty
rbw-fzf
];
2024-08-24 21:01:19 +00:00
};
}